Hello, wise monks!
I've been trying to construct parser for Clarion language and decided to start with simple things. After reading Parse::RecDescent's documentation, I took Parse::RecDescent Tutorial as an example to study and modify. The article has a code example which parses different code pieces, among which there's a code with assignment and printing of value: $parser->startrule("a = 5 ; print a"); That works fine. Until there're other instructions after print_instruction, in which case it fails to parse anything after first print:
Investigating parser trace I've found that the only text which is consumed for the entire input is [a = 5 ; print].$parser->startrule("a = 5 ; print a ; print a"); # this fails $parser->startrule("a = 5 ; print a ; b = 1"); # this fails either
Can wise monks help to understand, why the argument to print isn't consumed? And how to rewrite those rules for print_instruction to work correctly?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |