Created
April 10, 2017 11:49
-
-
Save anonymous/0c156ced8135f1ef09a8ac34fc6d03e9 to your computer and use it in GitHub Desktop.
perl6 grammar, recursions, actions
This file contains 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
grammar logical-expr-grammer { | |
rule TOP { | |
^ <expression> $ | |
} | |
token identifier { | |
<[A..Za..z0..9_-]>+ | |
} | |
rule term { | |
<identifier> | |
| '(' <expression> ')' | |
} | |
rule expression { | |
# XXX this triggers term multiple time, is that good? | |
<term> '|' <expression> | |
| <term> '&' <expression> | |
| '!' <term> | |
| <term> | |
} | |
} | |
class Actions { | |
method term($/) { | |
say "## term action"; | |
} | |
} | |
logical-expr-grammer.parse('varA', actions => Actions.new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment