Created
October 3, 2014 02:51
-
-
Save raydiak/70f73bc4f65f35f20553 to your computer and use it in GitHub Desktop.
cyclical rule problem
This file contains hidden or 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
#!/usr/bin/env perl6 | |
use v6; | |
grammar Problem { | |
token TOP { <expression> } | |
rule expression { <operation> | <value> } | |
rule operation {<expression> <operator> <expression>} | |
token operator { \+ | \- | \* | \/ } | |
token value { \d+ } | |
} | |
grammar NoProblem is Problem { | |
# the only difference here is that the rules have been changed to tokens | |
token expression { <operation> | <value> } | |
token operation {<expression> <operator> <expression>} | |
} | |
NoProblem.parse("1").perl.say; # expected result | |
Problem.parse("1").perl.say; # infinite loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment