mirror of
https://github.com/TheRealOwenRees/pgn_to_tex.git
synced 2026-07-23 12:06:58 +00:00
79155255f6
* copy project root files * import previously created code and rename where needed * fix license and lint * main is now just a JS wrapper * minified main.cjs rather than copying to a newly named file
36 lines
704 B
OCaml
36 lines
704 B
OCaml
%{
|
|
open Ast
|
|
%}
|
|
|
|
%token TAG_OPEN TAG_CLOSE LPAREN RPAREN EOF
|
|
%token <string> HEADER STRING MOVE NUMBER COMMENT RESULT CLOCK NAG
|
|
|
|
%start <Ast.game> main
|
|
|
|
%%
|
|
|
|
main:
|
|
| ts = tags; c = content; r = option(RESULT); EOF
|
|
{ { tags = ts; content = c; result = r } }
|
|
|
|
tags:
|
|
| TAG_OPEN; k = HEADER; v = STRING; TAG_CLOSE; rest = tags
|
|
{ { key = k; value = v } :: rest }
|
|
| (* empty *)
|
|
{ [] }
|
|
|
|
content:
|
|
| i = item; rest = content
|
|
{ i :: rest }
|
|
| (* empty *)
|
|
{ [] }
|
|
|
|
item:
|
|
| m = MOVE { Move m }
|
|
| n = NUMBER { Number n }
|
|
| c = CLOCK { Clock c }
|
|
| g = NAG { Nag g }
|
|
| c = COMMENT { Comment c }
|
|
| r = RESULT { Result r }
|
|
| LPAREN; v = content; RPAREN { Variation v }
|