Files
pgn_to_tex/lib/parser.mly
T
owenrees 79155255f6 Transfer code (#1)
* 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
2026-05-28 12:35:03 +02:00

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 }