[Pratt parser] Simplify helper methods and inlining - #1442
Merged
dmitriplotnikov merged 1 commit intoAug 28, 2026
Conversation
Inline single-callsite helper functions (initTokenStream, parse, newLogicManager, receiverCallOrMacro, globalCallOrMacro) to simplify pratt_parser.go while preserving stack frame sizes and recursive descent performance boundaries. | Category | ANTLR (Max Depth OK) | Pratt (Max Depth OK) | Pratt Advantage | | :--- | :--- | :--- | :--- | | **Parens** (`(((...42...)))`) | 20 | unlimited | **unlimited** | | **Unary** (`! ! ! ... true`) | unlimited | unlimited | **1.0x** | | **Binary** (`1 + (1 + (...42...))`) | 21 | 93 | **~4.4x** | | **List** (`[[[...42...]]]`) | 18 | 85 | **~4.7x** | | Benchmark Category | ns/op | B/op | allocs/op | | :--- | :--- | :--- | :--- | | **Simple** | 27,429 ns/op | 13,535 B/op | 404 allocs/op | | **Complex** | 107,297 ns/op | 51,864 B/op | 1,397 allocs/op | | **Macros** | 50,519 ns/op | 23,883 B/op | 641 allocs/op | | **Errors** | 83,839 ns/op | 37,764 B/op | 1,176 allocs/op | | **Parallel/Simple** | 6,732 ns/op | 13,494 B/op | 404 allocs/op | | **Parallel/Complex** | 26,721 ns/op | 51,865 B/op | 1,397 allocs/op | | **Parallel/Macros** | 11,902 ns/op | 23,732 B/op | 641 allocs/op | | **Parallel/Errors** | 21,489 ns/op | 37,659 B/op | 1,176 allocs/op |
TristonianJones
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Simplifies
pratt_parser.goby inlining single-callsite helper functions (initTokenStream,parse,newLogicManager,receiverCallOrMacro,globalCallOrMacro), while maintaining distinct branches for-and!and preserving recursive descent stack frame sizes.Recursion Depth Test (Stack: 64 KB)
(((...42...))))! ! ! ... true)1 + (1 + (...42...)))[[[...42...]]])Benchmark Results (Sequential & Parallel)