1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
%{
open Ast_types
%}
%token COMMA
%token <string> IDENTIFIER
%token UUIDV4
%token NEWLINE
%token SEMICOLON
%token NAME
%token COLON
%token DOT
%token EOF
%token INTSYMBOL
%token <int> INT
%token LBRACE
%token RBRACE
%start <ast_table option > prog
%%
prog:
| e = expr; EOF { Some e }
;
expr:
| tbl = IDENTIFIER; LBRACE; amount = INT; RBRACE; COLON; r = row; NEWLINE; e = expr { Table (tbl, amount, r, e) }
| tbl = IDENTIFIER; LBRACE; amount = INT; RBRACE; COLON; r = row; SEMICOLON; e = expr { Table (tbl,amount, r, e) }
| tbl = IDENTIFIER; LBRACE; amount = INT; RBRACE; COLON; r = row { Table (tbl,amount, r, End) }
;
row:
| row_title = IDENTIFIER; parent = IDENTIFIER; DOT; parent_id = IDENTIFIER; COMMA; r = row { Foreign (parent,parent_id,row_title, r) }
| row_title = IDENTIFIER; parent = IDENTIFIER; DOT; parent_id = IDENTIFIER; { Foreign (parent,parent_id,row_title, End) }
| row_title = IDENTIFIER; UUIDV4; COMMA; r = row { Uuidv4 (row_title, r) }
| row_title = IDENTIFIER; UUIDV4 { Uuidv4 (row_title, End) }
| row_title = IDENTIFIER; NAME; COMMA; r = row { Name (row_title, r) }
| row_title = IDENTIFIER; NAME { Name (row_title, End) }
| row_title = IDENTIFIER; INTSYMBOL;LBRACE;min = INT;COMMA;max = INT;RBRACE;COMMA; r = row { Int (row_title,min,max,r) }
| row_title = IDENTIFIER; INTSYMBOL;LBRACE;min = INT;COMMA;max = INT;RBRACE; { Int (row_title,min,max,End) }
;
|