aboutsummaryrefslogtreecommitdiff
path: root/lib/parser.mly
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2023-12-20 20:46:00 -0600
committerMarc Coquand <marc@mccd.space>2023-12-25 18:22:59 -0600
commit262f161f42c4e59beec41c6f440336c38385426a (patch)
tree6491c9b661a0b5a14c9a30ecf25e036f8762239d /lib/parser.mly
parentcc783c157f31e7e713c8b83be67449b1859dac27 (diff)
downloadfixgen-262f161f42c4e59beec41c6f440336c38385426a.tar.gz
fixgen-262f161f42c4e59beec41c6f440336c38385426a.tar.bz2
fixgen-262f161f42c4e59beec41c6f440336c38385426a.zip
Initial commit
Diffstat (limited to 'lib/parser.mly')
-rw-r--r--lib/parser.mly31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/parser.mly b/lib/parser.mly
new file mode 100644
index 0000000..f2f53fd
--- /dev/null
+++ b/lib/parser.mly
@@ -0,0 +1,31 @@
+%{
+ open Ast_types
+%}
+%token COMMA
+%token <string> IDENTIFIER
+%token UUIDV4
+%token NEWLINE
+%token NAME
+%token COLON
+%token DOT
+%token EOF
+%start <ast_table option > prog
+%%
+
+prog:
+ | e = expr; EOF { Some e }
+ ;
+
+expr:
+ | tbl = IDENTIFIER; COLON; r = row; NEWLINE; e = expr { Table (tbl,r, e) }
+ | tbl = IDENTIFIER; COLON; r = row { Table (tbl,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) }
+ ;