Skip to content

Instantly share code, notes, and snippets.

@ronaldxs
Created March 27, 2018 17:58
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 ronaldxs/c8755a791373afb89240e6525a436d7f to your computer and use it in GitHub Desktop.
Save ronaldxs/c8755a791373afb89240e6525a436d7f to your computer and use it in GitHub Desktop.
P6 looks like it is incorrectly matching a token backwards for some reason
#use Grammar::Tracer;
grammar g {
token keywords { 'or' }
token BASEIDENT {\w+<!after <keywords>>}
token BASEIDENT_SIMPLER {\w+<!after 'or'>}
token TOP { <BASEIDENT> }
}
say so g.parse('a');
say so g.parse('ro'); # this should match - looks wrong
say so g.parse('ro', :rule<BASEIDENT>); # same as above as expected
say so g.parse('ro', :rule<BASEIDENT_SIMPLER>); # different from above
my token keywordz {
'or'
}
say so "a" ~~ /\w+<!after <keywordz>>/;
say so "ro" ~~ /\w+<!after <keywordz>>/;
# Grammar::Tracer shows ro matching or
# TOP
# | BASEIDENT
# | | keywords
# | | * MATCH "or"
# | * FAIL
# * FAIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment