Skip to content

Instantly share code, notes, and snippets.

@skids
Created March 17, 2015 02:51
Show Gist options
  • Save skids/9450e905562ca7fb6ee3 to your computer and use it in GitHub Desktop.
Save skids/9450e905562ca7fb6ee3 to your computer and use it in GitHub Desktop.
Strange behaviors in rx interpolation
grammar gram {
my @stuff1 = rx/12/, rx/'='/, rx/<gram::foo>/;
my @stuff2 = rx/12/, rx/'='/, rx/bar/;
rule foo {bar};
regex s1a { @stuff1* % ' '}
regex s1b { <@stuff1>* % ' '}
regex s2a { @stuff2* % ' '}
regex s2b { <@stuff2>* % ' '}
regex q1a { @stuff1* }
regex q1b { <@stuff1>* }
regex q2a { @stuff2* }
regex q2b { <@stuff2>* }
}
say so gram.parse('12 = bar', :rule<s1a>); # Works and should fail
say so gram.parse('12 = bar', :rule<s1b>); # Fails and should work
say so gram.parse('12 = bar', :rule<s2a>); # Works and should fail
say so gram.parse('12 = bar', :rule<s2b>); # Works as it should
say so gram.parse('12=bar', :rule<q1a>); # Works and should fail
say so gram.parse('12=bar', :rule<q1b>); # Works as it should
say so gram.parse('12=bar', :rule<q2a>); # Works and should fail
say so gram.parse('12=bar', :rule<q2b>); # Works as it should
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment