Created
March 17, 2015 02:51
-
-
Save skids/9450e905562ca7fb6ee3 to your computer and use it in GitHub Desktop.
Strange behaviors in rx interpolation
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 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