| 12345678910111213141516171819202122232425262728293031 |
- %{
- open Lexing
- open Types
- %}
- (* tokens *)
- %token SEMICOL EXCLAM PLUS MINUS OMEGA LPAREN RPAREN HASH
- %token <int> NUMBER
- %token <char> UPPER LOWER
- %token EOF
- (* start symbol *)
- %type <Types.program> program
- %start program
- %%
- program:
- | instrs=separated_list(SEMICOL, instruction) EOF
- { instrs }
- instruction:
- | c=LOWER { Basic c }
- | EXCLAM { Terminate }
- | PLUS c=LOWER { Ptest c }
- | MINUS c=LOWER { Ntest c }
- | HASH n=NUMBER { Jump n }
- | i=instruction n=NUMBER { Repeat (i, n) }
- | i=instruction OMEGA { Loop i }
- | c=UPPER { Program c }
- | LPAREN i=separated_list(SEMICOL, instruction) RPAREN { Concat i }
|