Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser clean-up #31

Merged
merged 3 commits into from
Apr 16, 2020
Merged

Parser clean-up #31

merged 3 commits into from
Apr 16, 2020

Conversation

travisbrown
Copy link
Owner

This is something I started last week—it's some improvements to the JavaCC parser that shave off a few hundred lines of code. The bulk of those come from rewriting the operator parsing to use "precedence climbing", to use the terminology of this article, instead of the "classic solution" (one non-terminal per precedence level).

This isn't really directly related to #1 or #2, but it makes editing the JavaCC grammar and digging through the JavaCC debugging output a little less painful. It should have no effect on the behavior of the parser.

As a side effect, it seems to speed up the parser a bit. For example, parsing the normalized prelude is around 6% faster in a benchmark I've included here. Before:

Benchmark                       Mode  Cnt   Score   Error  Units
ParsingBenchmark.parsePrelude  thrpt   20  15.305 ± 0.056  ops/s

After:

Benchmark                       Mode  Cnt   Score   Error  Units
ParsingBenchmark.parsePrelude  thrpt   20  16.235 ± 0.118  ops/s

The jar is also slightly smaller (104K instead of 108). Both of those improvements were non-goals, though, and I would have been happy to see either go the other way.

@travisbrown travisbrown merged commit ca9baaa into master Apr 16, 2020
@travisbrown travisbrown deleted the topic/parser-clean-up branch April 17, 2020 11:25
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.

1 participant