A lot of work to the manual for 0.3.
[gazelle.git] / sketches / lua.gzl
blob5cd5e8e5e375bfcbf4e518f1eec09eead691a601
2 Name: /[:alpha:_][:alnum:_]* ~
3        (and|break|do|else|elseif|end|false|for|function|if|in|
4         local|nil|not|or|repeat|return|then|true|until|while)/
6 Number: /[0-9]* (\. [0-9]+)? ([Ee] [+-]? [0-9]+)? | 0x[0-9A-Fa-f]+/;
8 chunk ->  (stat ";"?) *  (laststat ";"?) ? ;
9 block -> chunk;
11 stat[assign]    -> varlist "=" explist;
12 stat[funccall]  -> functioncall;
13 stat[do]        -> "do" block "end";
14 stat[while]     -> "while" exp "do" block "end";
15 stat[repeat]    -> "repeat" block "until" exp;
16 stat[if]        -> "if" exp "then" block ("elseif" exp "then" block)* ("else" block)? "end";
17 stat[for]       -> "for" Name "=" exp "," exp ("," exp)? "do" block "end";
18 stat[funcdef]   -> "function" funcname funcbody;
19 stat[localfunc] -> "local" "function" Name funcbody;
20 stat[localvars] -> "local" namelist ("=" explist)?
22 laststat -> "return" explist? | "break"
24 funcname -> Name +(.) (":" Name)?
26 varlist  -> var +(,)
27 var      -> Name | prefixexp "[" exp "]" | prefixexp "." Name
28 namelist -> Name +(,)
30 exp -> "nil" | "false" | "true" | Number | string | "..." | function |
31        prefixexp | tableconstructor | @expr(ops)
33 @oplist ops: 2< "or",
34              2< "and",
35              2< "<" | 2< ">" | 2< "<=" | 2< ">=" | 2< "~=" | 2< "==",
36              2> "..",
37              2< "+" | < "-",
38              2< "*" | < "/" | < "%",
39              1< "not" | 1< "#" | 1< "-",
40              2> "^";
42 prefixexp    -> var | functioncall | "(" exp ")"
43 functioncall -> prefixexp args | prefixexp ":" Name args
44 args         -> "(" explist? ")" | tableconstructor | String
46 function     -> "function" funcbody
47 funcbody     -> "(" parlist? ")" block "end"
48 parlist      -> namelist "," "..." | "..."
50 tableconstructor -> "{" fieldlist? "}"
51 fieldlist -> field +(fieldsep) fieldsep?
52 field -> "[" exp "]" "=" exp | Name "=" exp | exp
53 fieldsep: /[,;]/