nand2tetris/compiler/lib/be_parser.mly

25 lines
442 B
OCaml
Raw Normal View History

2022-08-03 13:04:42 +00:00
%{
open Be_ast
%}
%token <string> ADDRESS
%token <string> COMMAND
%token <string> SEGMENT
%token <string> COMMENT
%token EOF
%start <Be_ast.expr> prog
%%
prog:
| e = expr; EOF { e }
;
expr:
| c = COMMENT { Comment c }
| c = COMMAND; { Acommand c }
| c = COMMAND; s = SEGMENT; a = ADDRESS { Mcommand (c, s, a) }
| e = expr; COMMENT { e }
;