Make list productions left-recursive
This commit is contained in:
@@ -26,24 +26,33 @@ rung:
|
||||
| steps SEMICOLON EOF { Rung $1 }
|
||||
|
||||
steps:
|
||||
| steps_reversed { List.rev $1 }
|
||||
|
||||
steps_reversed:
|
||||
| { [] }
|
||||
| instr steps { StepInstr $1 :: $2 }
|
||||
| branch steps { StepBranch $1 :: $2 }
|
||||
| steps_reversed instr { StepInstr $2 :: $1 }
|
||||
| steps_reversed branch { StepBranch $2 :: $1 }
|
||||
|
||||
branch:
|
||||
| LEFT_BRACKET branch_arms RIGHT_BRACKET { Branch $2 }
|
||||
|
||||
branch_arms:
|
||||
| branch_arms_reversed { List.rev $1 }
|
||||
|
||||
branch_arms_reversed:
|
||||
| { [] }
|
||||
| steps COMMA branch_arms { BranchArm $1 :: $3}
|
||||
| branch_arms_reversed COMMA steps { BranchArm $3 :: $1}
|
||||
| steps { [ BranchArm $1 ] }
|
||||
|
||||
instr:
|
||||
| IDENTIFIER LEFT_PAREN operands RIGHT_PAREN { { Op = $1; Args = $3 } }
|
||||
|
||||
operands:
|
||||
| operands_reversed { List.rev $1 }
|
||||
|
||||
operands_reversed:
|
||||
| { [] }
|
||||
| operand COMMA operands { $1 :: $3 }
|
||||
| operands_reversed COMMA operand { $3 :: $1 }
|
||||
| operand { [ $1 ] }
|
||||
|
||||
operand:
|
||||
|
Reference in New Issue
Block a user