Parse single instruction in neutral text
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
%{
|
||||
open LDText.Ast
|
||||
// helper functions
|
||||
open FSharp.Text.Lexing
|
||||
%}
|
||||
|
||||
// start token
|
||||
%start start
|
||||
%start instr
|
||||
|
||||
// tokens, used by lexer
|
||||
%token <string> IDENTIFIER
|
||||
@@ -18,19 +18,20 @@ open LDText.Ast
|
||||
%token EOF
|
||||
|
||||
// return type of parser, marked by start token
|
||||
%type <Rung option> rung
|
||||
%type <Instr> instr
|
||||
|
||||
%%
|
||||
|
||||
start:
|
||||
| instr EOF { $1 }
|
||||
//rung:
|
||||
// | instr EOF { $1 }
|
||||
|
||||
instr:
|
||||
| IDENTIFIER LEFT_PAREN operands RIGHT_PAREN { StepInstr { Op = $1; Args = [ $3 ] } }
|
||||
| IDENTIFIER LEFT_PAREN operands RIGHT_PAREN { { Op = $1; Args = $3 } }
|
||||
|
||||
operands:
|
||||
| { }
|
||||
| operand operands { $1; $2 }
|
||||
| { [] }
|
||||
| operand COMMA operands { $1 :: $3 }
|
||||
| operand { [ $1 ] }
|
||||
|
||||
operand:
|
||||
| IDENTIFIER { OperandTag $1 }
|
||||
|
Reference in New Issue
Block a user