/* Based on: https://github.com/R167/lezer-lua */ @precedence { call, power @right, prefix, times @left, plus @left, concat @right, shift @left, bitand @left, xor @left, bitor @left, compare @left, and @left, or @left } @top Chunk { Block } Block { statement* ReturnStatement? } ReturnStatement { kw<"return"> ExpList? ";"?} @skip { newline | space | Comment } statement[@isGroup=Statement] { ";" | Label | kw<"break"> | Goto{ kw<"goto"> Name } | Scope { kw<"do"> Block kw<"end"> } | WhileStatement { kw<"while"> exp kw<"do"> Block kw<"end"> } | RepeatStatement { kw<"repeat"> Block kw<"until"> exp } | IfStatement | ForStatement | Function { kw<"function"> FuncName FuncBody } | LocalFunction { kw<"local"> kw<"function"> Name FuncBody } | Assign { VarList "=" ExpList } | Local { kw<"local"> AttNameList ("=" ExpList)? } | FunctionCall ~fcall } IfStatement { kw<"if"> exp kw<"then"> Block (kw<"elseif"> exp kw<"then"> Block)* (kw<"else"> Block)? kw<"end"> } ForNumeric { Name "=" exp "," exp ("," exp)? } ForGeneric { NameList kw<"in"> ExpList } ForStatement { kw<"for"> (ForNumeric | ForGeneric) kw<"do"> Block kw<"end"> } FuncName { Name ("." Name)* (":" Name)? } FuncBody { "(" ArgList ")" Block kw<"end"> } list { term ("," term)* } NameList { list } ExpList { list } VarList { list } ArgList { (list)? } AttNameList { list } AttName { Name Attrib } Attrib { ( "<" Name ">" )? } exp { kw<"nil"> | kw<"true"> | kw<"false"> | "..." | Number | LiteralString | prefixexp | BinaryExpression | UnaryExpression | TableConstructor | FunctionDef { kw<"function"> FuncBody } // | Query } Query { "[" exp QueryClause* "]" } QueryClause { WhereClause | OrderByClause | SelectClause | RenderClause | LimitClause } WhereClause { kw<"where"> exp } LimitClause { kw<"limit"> exp } OrderByClause { kw<"order"> kw<"by"> exp kw<"desc">? } SelectClause { kw<"select"> list