Skip to content

[Pratt parser] Port Pratt parser from cel/cpp - #1427

Merged
dmitriplotnikov merged 5 commits into
masterfrom
pratt-parser
Aug 21, 2026
Merged

[Pratt parser] Port Pratt parser from cel/cpp#1427
dmitriplotnikov merged 5 commits into
masterfrom
pratt-parser

Conversation

@dmitriplotnikov

@dmitriplotnikov dmitriplotnikov commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

This PR ports the Pratt parser and hand-written lexer from github.com/cel-expr/cel-cpp/tree/master/parser/internal.

Highlights:

  • PrattParser: Adds a recursive-descent top-down operator precedence (Pratt) parser implementation.
  • Fast Lexer: Adds a dedicated lexer (parser/lexer.go) replacing ANTLR lexing with single-pass rune scanning.
  • Performance: Pratt parser demonstrates significant performance improvements over ANTLR in BenchmarkParsers:
    • 8.4x – 14.8x faster execution time
    • 6.0x – 12.5x less memory consumed
    • 4.2x – 6.6x fewer memory allocations

This parser is still WIP and should not yet be used by clients of cel-go

Comment thread parser/lexer.go
Comment thread parser/lexer_test.go
Comment thread parser/lexer.go
Comment thread parser/pratt_parser.go Outdated
Comment thread parser/pratt_parser.go
Comment thread parser/pratt_parser.go
Comment thread parser/pratt_parser.go
Comment thread parser/pratt_parser.go Outdated
@dmitriplotnikov
dmitriplotnikov requested review from TristonianJones and removed request for jnthntatum August 20, 2026 23:19
@dmitriplotnikov
dmitriplotnikov merged commit 7bd18ac into master Aug 21, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants