Skip to content

Instantly share code, notes, and snippets.

Created April 10, 2017 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0c156ced8135f1ef09a8ac34fc6d03e9 to your computer and use it in GitHub Desktop.
Save anonymous/0c156ced8135f1ef09a8ac34fc6d03e9 to your computer and use it in GitHub Desktop.
perl6 grammar, recursions, actions
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