Parse branches
This commit is contained in:
@@ -18,16 +18,25 @@ open FSharp.Text.Lexing
|
||||
%start rung
|
||||
|
||||
// return type of parser, marked by start token
|
||||
%type <Instr list> rung
|
||||
%type <Rung> rung
|
||||
|
||||
%%
|
||||
|
||||
rung:
|
||||
| steps SEMICOLON EOF { $1 }
|
||||
| steps SEMICOLON EOF { Rung $1 }
|
||||
|
||||
steps:
|
||||
| { [] }
|
||||
| instr steps { $1 :: $2 }
|
||||
| instr steps { StepInstr $1 :: $2 }
|
||||
| branch steps { StepBranch $1 :: $2 }
|
||||
|
||||
branch:
|
||||
| LEFT_BRACKET branch_arms RIGHT_BRACKET { Branch $2 }
|
||||
|
||||
branch_arms:
|
||||
| { [] }
|
||||
| steps COMMA branch_arms { BranchArm $1 :: $3}
|
||||
| steps { [ BranchArm $1 ] }
|
||||
|
||||
instr:
|
||||
| IDENTIFIER LEFT_PAREN operands RIGHT_PAREN { { Op = $1; Args = $3 } }
|
||||
|
Reference in New Issue
Block a user