Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created April 21, 2017 12:26
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 jnthn/f26b1ed53e6ee12d7f2f88256523af0e to your computer and use it in GitHub Desktop.
Save jnthn/f26b1ed53e6ee12d7f2f88256523af0e to your computer and use it in GitHub Desktop.
grammar Parser {
token TOP { <matcher>+ }
proto token matcher { * }
token matcher:sym<[]> { '[' <( <-[\]]>+ )> ']' }
token matcher:sym<lit> { <-[/*?[]>+ }
}
class RuleCompiler {
# Simply commenting out this causes the matcher:sym<lit> to get the .txt it should. With
# this, it gets ].txt instead.
method matcher:sym<[]>($/) { }
}
say Parser.parse('[AB].txt', :actions(RuleCompiler));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment