Skip to content

Conversation

@jessejenks
Copy link
Owner

@jessejenks jessejenks commented Apr 4, 2021

Pratt style parsers for better operator precedence and associativity control.

Still needs API improvements.

@jessejenks jessejenks marked this pull request as ready for review May 21, 2021 20:52
Adds a basic Pratt parser. Currently this is limited to binary infix
operators. New operators can be defined with a pair of numbers
representing the "binding power" of the operator. This pair determines
the precedence of the operator and whether it should associate to the
left or right.

Adds an example which demonstrates this and how it compares to the
"standard" BNF style approach which produces only right associating
parsers.
Updates the api for passing infix operators to a Pratt parser.
Adds functionality for parsing prefix operators.

Adds tests for postfix operators.
Adds functionality for parsing postfix operators.

Adds tests for postfix operators.
Adds functionality for denoting scope in a Pratt parser. For example
`1 * (2 + 3)` instead of `(1 * 2) + 3`.
Moves the example showcasing Pratt parser features into a separate file.
Adds more type parameters to generalize types for operators. This means
operators can have types attached to them and are no longer required to
be strings.

Updates terminology from "map" to "acc" for 'accumulator'. This is a
slightly more accurate description of how this function is meant to be
used.
Adds an example of attaching types to operators when defining a Pratt
parser.
Catches up pratt parser branch to main and updates to use the new parse
result format.
@jessejenks jessejenks changed the title Adds basic Pratt parser Adds Pratt parser May 21, 2021
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