Parse multiple instructions

This commit is contained in:
2025-09-07 21:58:37 -06:00
parent 925e486e65
commit 43107e7435
4 changed files with 117 additions and 58 deletions

View File

@@ -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 } }