r/Protos • • 2d ago

Building a self-hosted parser exposed 11 discrepancies in the original Java parser of Protos

One interesting benefit of building a programming language parser in its own language is discovering inconsistencies in the original implementation.

While developing the Protos-written parser, differential testing revealed 11 structural discrepancies in the existing Java frontend.

The problem involved contextual keywords, reserved member names, mutation targets and significant newlines.

Instead of adapting the new parser to reproduce the original behavior, the existing frontend was corrected to follow the language specification.

The result:

  • All 11 discrepancies resolved.
  • 37 focused regression tests passing.
  • Integrated local tests passing.
  • No new Java classes or runtime infrastructure.

Projects such as CPython, GraalPy and GraalJS offer interesting perspectives on parser architecture and contextual syntax recognition.

Protos is taking incremental steps toward a self-hosted frontend while preserving its GraalVM and Truffle execution architecture.

What parsing strategy would you choose when moving a language toward self-hosting: handwritten recursive descent, PEG, or a generated parser?

https://github.com/guillermomolina/protos

1 Upvotes

0 comments sorted by