module Grammars
Defined in:
grammar2parser/grammars.cr
Constant Summary
-
GrammarDict =
{sql: GRAMMARSQL, sqlschema: GRAMMARSQLSCHEMA}
-
GRAMMARSQL =
[{rule: "Program", body: " comments* with?\n ((\"SHOW\" (\"TABLES\" | ( \"TABLE\" AS_TID))) \n | \"INSERT\" insertbody \n | \"SELECT\" projectbody orderby? limit? \n | \"UPDATE\" updatebody \n | \"DELETE\" deletebody) \";\" ;"}, {rule: "comments", body: "\"-- \" fullrow_Lx ;"}, {rule: "with", body: " \"WITH\" ((withplain,',')) ? withrecur? ; "}, {rule: "withplain", body: " tablename \"(\" column_comma_list \")\" \"AS\" \"(\" \"SELECT\" projectbody \")\" ; "}, {rule: "withrecur", body: " \"RECURSIVE\" tablename \"(\" column_comma_list \")\" \"AS\" \"(\" \"SELECT\" projectbody \"UNION\" \"ALL\"? \"SELECT\" projectbody \")\" ; "}, {rule: "insertbody", body: " \"INTO\" (Identifier_Lx | SQString_Lx tbl_col_alias) \"(\" column_comma_list \")\" value_or_select ;"}, {rule: "value_or_select", body: " (\"VALUES\" value_list) | (\"SELECT\" projectbody) ;"}, {rule: "updatebody", body: " (Identifier_Lx | SQString_Lx tbl_col_alias) \"SET\" ( AS_CID \"=\" scalarexp ),',' whererule ;"}, {rule: "deletebody", body: " \"FROM\" (Identifier_Lx | SQString_Lx tbl_col_alias) whererule ;"}, {rule: "projectbody", body: " \"DISTINCT\"? project \"FROM\" from whererule? window? groupby? having? ;"}, {rule: "from", body: " table_ref ;"}, {rule: "table_ref", body: " relation_body joiner_or_setoper* ;"}, {rule: "relation_body", body: " ( \"(\" relation_body \")\" tbl_col_alias )\n | \"VALUES\" value_list tbl_col_alias?\n | \"SELECT\" projectbody\n | tablename tbl_col_alias? ;"}, {rule: "value_list", body: " ( \"(\" ( DQString_Lx | SQString_Lx | Number_Lx ) ,',' \")\" ),',' ;"}, {rule: "tbl_col_alias", body: "\"AS\" AS_TID ( \"(\" column_comma_list \")\" )?;"}, {rule: "joiner_or_setoper", body: "\n ( \",\" relation_body ) |\n ( ( \"JOIN\" | ( join_type \"JOIN\" ) ) relation_body onrule)\n | ((\"UNION\" | \"EXCEPT\" | \"INTERSECT\") \"ALL\"? relation_body)\n | (\"CROSS\" \"JOIN\" relation_body)\n ;"}, {rule: "join_type", body: "\"INNER\"\n | (\"LEFT\" | \"RIGHT\" | \"FULL\") \"OUTER\" ?\n | \"UNION\" ;"}, {rule: "whererule", body: " \"WHERE\" fullcondexpr ; "}, {rule: "onrule", body: " \"ON\" fullcondexpr ; "}, {rule: "fullcondexpr", body: " pcondexpr andor * ; "}, {rule: "andor", body: " (\"AND\" | \"OR\" ) pcondexpr ; "}, {rule: "pcondexpr", body: " (('(' condexpr ')') | condexpr ) ; "}, {rule: "condexpr", body: " simplecond | '(' condexpr ')' ; "}, {rule: "simplecond", body: " psimplecond compoper_Lx psimplecond ; "}, {rule: "psimplecond", body: " scalarexp | ('(' scalarexp ')') ; "}, {rule: "scalarexp", body: " nypscalarexp ( scalaroper_Lx nypscalarexp ) * ; "}, {rule: "nypscalarexp", body: " (\"VALUES\" value_list) | ( \"(\" scalarexpselectbodyorscalarexp \")\" ) | scalarterm ; "}, {rule: "scalarexpselectbodyorscalarexp", body: " ( \"SELECT\" projectbody ) | scalarexp ; "}, {rule: "scalarterm", body: "\n standardfunction\n | DQString_Lx\n | SQString_Lx\n | Number_Lx\n | TID\n | Param_Lx\n ; "}, {rule: "orderby", body: " \"ORDER\" \"BY\" ( (Identifier_Lx | Number_Lx ) (\"ASC\" | \"DESC\")? ),',' ;"}, {rule: "partby", body: " \"PARTITION\" \"BY\" ( TID ),',' ;"}, {rule: "limit", body: " \"LIMIT\" ( Number_Lx (\"OFFSET\" Number_Lx)? | (\",\" Number_Lx )? ); "}, {rule: "window", body: " \"WINDOW\" AS_TID \"AS\" \"(\" partby? orderby? \")\" ;"}, {rule: "groupby", body: " \"GROUP\" \"BY\" ( TID ),',' ;"}, {rule: "having", body: " \"HAVING\" fullcondexpr ;"}, {rule: "project", body: "((\"*\" | (nyprojectitem (\"AS\" AS_CID)?),',' )) (\"AS\" AS_TID)? ;"}, {rule: "nyprojectitem", body: " ( \"(\" projselectbodyorscalarexp \")\" ) | simpleprojectitem ; "}, {rule: "projselectbodyorscalarexp", body: " ( \"SELECT\" projectbody ) | scalarexp ; "}, {rule: "simpleprojectitem", body: " standardfunction | ( AS_TID ( (\".*\" | \".\" AS_CID ) )? | SQString_Lx | Number_Lx ) ; "}, {rule: "standardfunction", body: "( \"MIN\" | \"MAX\" | \"AVG\" | \"SUM\" | \"COUNT\" | \"STDDEV\" | \"TOUPPER\"| \"TOLOWER\" ) \"(\" TID? \")\" over? ;"}, {rule: "over", body: " \"OVER\" \"(\" AS_TID \")\" orderby? ; "}, {rule: "column_comma_list", body: "AS_CID,',';"}, {rule: "Literal_Cs", body: "['a' ~ 'z'] | ['A' ~ 'Z'] ;"}, {rule: "Digit09_Cs", body: "['0' ~ '9'] ;"}, {rule: "Digit19_Cs", body: "['1' ~ '9'] ;"}, {rule: "AS_TID", body: " Identifier_Lx ; "}, {rule: "AS_CID", body: "Identifier_Lx ;"}, {rule: "TID", body: " Identifier_Lx '.' Identifier_Lx ; "}]
-
GRAMMARSQLSCHEMA =
[{rule: "Createtable", body: " create \";\" ;"}, {rule: "create", body: "\n \"CREATE\" \"ENTITYTABLE\"\n \"(\" enttable + \")\"\n (\n \"RELATIONSHIPTABLE\" \"(\" reltable + \")\"\n )? ;\n "}, {rule: "enttable", body: "tablename entkey relcols? plaincols? ;"}, {rule: "reltable", body: "tablename relkey relcols? plaincols? ;"}, {rule: "entkey", body: "\"PRIMARYKEY\" \"(\" (acolumn,',') + \")\" ; "}, {rule: "relkey", body: "\"PRIMARYKEY\" \"(\"\n \"PARENTS\" \"(\"\n ( tablenameandmore,',' )+\n \")\"\n (\"OWNPRIMARY\" \"(\" (acolumn,',') + \")\" )?\n \")\";"}, {rule: "tablenameandmore", body: " tablename prefixed? sqlattribute? ;"}, {rule: "prefixed", body: " \"PREFIXED\" SQString_Lx ;"}, {rule: "acolumn", body: " colname sqlattribute? ;"}, {rule: "relcols", body: " \"RELATIVECOLUMN\" \"(\" (tablename prefixed?) ,',' \")\" ;"}, {rule: "plaincols", body: " \"PLAINCOLUMN\" \"(\" (acolumn,',')+ \")\" ;"}, {rule: "tablename", body: "Identifier_Lx ;"}, {rule: "colname", body: "Identifier_Lx ;"}, {rule: "Literal_Cs", body: "['a' ~ 'z'] | ['A' ~ 'Z'] ;"}, {rule: "Digit09_Cs", body: "['0' ~ '9'] ;"}, {rule: "Digit19_Cs", body: "['1' ~ '9'] ;"}, {rule: "sqlattribute", body: " SQString_Lx ;"}, {rule: "Identifier_Lx", body: "Literal_Cs (Literal_Cs | Digit09_Cs | '_')* ;"}]