Parse multiple instructions
This commit is contained in:
@@ -3,9 +3,6 @@ open LDText.Ast
|
||||
open FSharp.Text.Lexing
|
||||
%}
|
||||
|
||||
// start token
|
||||
%start instr
|
||||
|
||||
// tokens, used by lexer
|
||||
%token <string> IDENTIFIER
|
||||
%token LEFT_PAREN
|
||||
@@ -17,13 +14,20 @@ open FSharp.Text.Lexing
|
||||
%token QUESTION_MARK
|
||||
%token EOF
|
||||
|
||||
// start token
|
||||
%start rung
|
||||
|
||||
// return type of parser, marked by start token
|
||||
%type <Instr> instr
|
||||
%type <Instr list> rung
|
||||
|
||||
%%
|
||||
|
||||
//rung:
|
||||
// | instr EOF { $1 }
|
||||
rung:
|
||||
| steps SEMICOLON EOF { $1 }
|
||||
|
||||
steps:
|
||||
| { [] }
|
||||
| instr steps { $1 :: $2 }
|
||||
|
||||
instr:
|
||||
| IDENTIFIER LEFT_PAREN operands RIGHT_PAREN { { Op = $1; Args = $3 } }
|
||||
|
Reference in New Issue
Block a user