Created
May 14, 2011 08:08
-
-
Save xrl/972037 to your computer and use it in GitHub Desktop.
First attempt at lua grammar...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% name = Lupin::Parser | |
chunk = (stat ";"?)* (laststat ";"?)? | |
block = chunk | |
stat = varlist "=" explist | | |
functioncall | | |
"do" block "end" | | |
"while" exp "do" block "end" | | |
"repeat" block "until" exp | | |
"if" exp "then" block ("elseif" exp "then" block)* ("else" block)? "end" | | |
"for" name "=" exp "," exp ("," exp)? "do" block "end" | | |
"for" namelist "in" explist "do" block "end" | | |
"function" funcname funcbody | | |
"local" "function" name funcbody | | |
"local" namelist ("=" explist)? | |
laststat = "return" (explist)* | "break" | |
funcname = name ("." name)* (":" name)? | |
varlist = var ("," var) | |
var = name | prefixexp "[" exp "]" | prefixexp "." name | |
namelist = name ("," name)* | |
explist = (exp ",")* exp | |
exp = "nil" | "false" | "true" | number | string | "..." | function | prefixexp | | |
tableconstructor | exp binop exp | unop exp | |
prefixexp = var | functioncall | "(" exp ")" | |
functioncall = prefixexps args | prefixexp ":" name args | |
args = "(" (explist)? ")" | tableconstructor | string | |
function = function funcbody | |
funcbody = "(" (parlist)? ")" block "end" | |
parlist = namelist ("," "...") | "..." | |
tableconstructor = "{" fieldlist "}" | |
fieldlist = field (fieldsep field)* (fieldsep)? | |
field = "[" exp "]" "=" exp | name "=" exp | exp | |
fieldsep = "," | ";" | |
binop = "+" | "-" | "*" | "/" | "^" | "%" | ".." | "<" | "<=" | ">" | ">=" | "==" | "~=" | "and" | "or" | |
unop = "-" | "not" | "#" | |
root = chunk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment