cyclical rule problem
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
| #!/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