ptal / oak

A typed parser generator embedded in Rust code for Parsing Expression Grammars
Apache License 2.0
142 stars 14 forks source link

Tree pattern matching #80

Closed ptal closed 3 years ago

ptal commented 8 years ago

Extend the parser with "tree-shape" atoms. This will allow to provide pattern matching on enum type and for example, to directly work with the Rust compiler Lexer. Several notes:

Some references on this topic of tree-pattern matching with PEG:

ptal commented 8 years ago

Somewhat relevant to the discussion, if we use sum variant in semantic action, for example:

expr = addition > Addition
     /  substraction > Substraction

it becomes impossible to guess the type of the rule. We can extend the -> to specify any rust type and to be applied on rule (for convenience), the previous example becomes:

expr -> RustTy
        = addition > Addition
        /  substraction > Substraction

with RustTy the rust type.

ptal commented 8 years ago

Postponed because we will match on Rust tokens with another technique. This is still interesting for general pattern matching so I do not close this issue for now but, since we are in a typed context (which is different from OMeta), we might consider another approach later.

ptal commented 3 years ago

Triage: abandon this feature. We will focus on #93 instead.