WIP: nearley parser for the expression language #50

Draft
glen wants to merge 4 commits from nearley_parse into main
Owner

The latest in the series that started with #47 and #49, this time exploring the nearley parser, which appears fairly fast and in tests in #49, pretty lightweight.

Work on this PR is starting with a rule-based Tokenizr lexer. The Tokenizr package is quite powerful, so in this iteration I am putting a lot more detail into the lexing: it will handle bracket pairing so it can do the newline-ignoring inside nested expressions and report mismatched brackets even before parsing; it is fully parsing string tokens; it is annotating following tokens with comments that appear before them, etc. (The direction of comment-annotation is not always correct of course; people often comment what's just before. But moving comments into token annotations is much easier to the right than to the left!)

So hopefully with this much more powerful lexing phase, the grammar/parsing will be significantly clearer/easier/more concise.

The latest in the series that started with #47 and #49, this time exploring the nearley parser, which appears [fairly fast](https://chevrotain.io/performance/) and in tests in #49, pretty lightweight. Work on this PR is starting with a rule-based [Tokenizr](https://github.com/rse/tokenizr) lexer. The Tokenizr package is quite powerful, so in this iteration I am putting a lot more detail into the lexing: it will handle bracket pairing so it can do the newline-ignoring inside nested expressions and report mismatched brackets even before parsing; it is fully parsing string tokens; it is annotating following tokens with comments that appear before them, etc. (The direction of comment-annotation is not always correct of course; people often comment what's just before. But moving comments into token annotations is much easier to the right than to the left!) So hopefully with this much more powerful lexing phase, the grammar/parsing will be significantly clearer/easier/more concise.
feat: start a lexer for the expression language
Some checks failed
/ test (pull_request) Failing after 16s
59497f5113
feat: more token types
Some checks failed
/ test (pull_request) Failing after 17s
89ce689c67
feat: first full draft of lexer with decent test coverage
Some checks failed
/ test (pull_request) Failing after 18s
ccad800be8
Author
Owner

Update: nearley has some long-unmerged PRs that would be useful in completing this project, revealing that its state of being "maintained" has deteriorated. @josdejong and I are consulting about what the trajectory here should be in light of this observation.

Update: nearley has some long-unmerged PRs that would be useful in completing this project, revealing that its state of being "maintained" has deteriorated. @josdejong and I are consulting about what the trajectory here should be in light of this observation.
wip: partway through Nearley grammar, switch to parser-combinator
Some checks failed
/ test (pull_request) Failing after 19s
5a9e01e650
Some checks failed
/ test (pull_request) Failing after 19s
Required
Details
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin nearley_parse:nearley_parse
git switch nearley_parse
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
StudioInfinity/nanomath!50
No description provided.