Files
control-see/ldtext/Parser.fsy

39 lines
598 B
Plaintext

%{
open LDText.Ast
// helper functions
%}
// start token
%start start
// tokens, used by lexer
%token <string> IDENTIFIER
%token LEFT_PAREN
%token RIGHT_PAREN
%token LEFT_BRACKET
%token RIGHT_BRACKET
%token COMMA
%token SEMICOLON
%token QUESTION_MARK
%token EOF
// return type of parser, marked by start token
%type <Rung option> rung
%%
start:
| instr EOF { $1 }
instr:
| IDENTIFIER LEFT_PAREN operands RIGHT_PAREN { StepInstr { Op = $1; Args = [ $3 ] } }
operands:
| { }
| operand operands { $1; $2 }
operand:
| IDENTIFIER { OperandTag $1 }
| QUESTION_MARK { OperandHole }
%%