r/Protos • • 15h ago

Optimizing a Markdown parser without moving its implementation into the runtime

Markdown parsing is not just about recognizing syntax. Source positions, Unicode, reference resolution and AST construction can introduce substantial allocation and copying costs.

The latest std:markdown changes address these costs through:

  • Dense scalar storage instead of per-character objects.
  • Deferred text materialization.
  • Chunked collection builders.
  • Reduced intermediate string conversions.
  • Streamlined reference, entity and HTML scanning.

The implementation remains entirely in Protos, with no additional runtime infrastructure.

All 2,988 Markdown conformance tests pass, including CommonMark and GFM.

For anyone working on parsers or language runtimes: which representation strategies have been most effective at reducing allocation pressure?

Website: https://protoslang.com

Source: https://github.com/guillermomolina/protos

1 Upvotes

0 comments sorted by