[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua 5 Light
- From: "XenoLiz" <xenoliz@...>
- Date: Tue, 23 Oct 2007 10:22:59 +0600
It`s proposed
grammar(Byson) for ( Lua 5
Light, may be ), in style @Lua 5.1 Reference
Manual@
1 chunk:
laststat
2 |
stat;
3 block_ended:
laststat
4 |
stat_w_end;
6 stat_w_end: stat
"end";
7 laststat: stat "return"
args
8 |
stat "return"
9 | stat "break" "`[integral
const]`"
10 |
stat "break"
11
| stat "error" args;
12 function_def: "function" '('
parlist ')' block_ended
14 |
'\\' parlist '\\' block_ended;
16 parlist: /* empty
*/
17 |
"`...`"
18 | namelist
'|' "`...`"
19 |
namelist '|' Name
20 |
namelist;
21 namelist: namelist ','
Name
22 |
Name;
23 stat: /* empty */
24 | "use" varlist
// Lua: local sin, cos = math.sin, math.cos; Lua5L: use math.sin,
math.cos
25 | stat "if" if_unmatched
"else" block_ended
27 | stat "if"
if_unmatched "end"
28 | stat "loop"
stat_w_end // Lua: "while" "true"
stat_w_end
29 | stat "while" exp
stat_w_end
30 | stat "for" namelist '='
explist
stat_w_end
// Lua: for i=1,50 do...; for i=1,20,3 do...; for k,v in pair(t)
do...
//
Lua5L{as Clu, w/o 'in' &
'do'}:
// for i = from_to(1,50) ... for i = from_to_by(1,20,3) ... for k,v =
pair(t) ...
31 | stat "repeat" stat
"until" exp
32 | stat '#' varlist '|'
var '=' explist
33 | stat '#' varlist
'=' explist
34 | stat '?'
function_call
35 | stat "local"
namelist
36 | stat "local" namelist '|'
Name '=' explist
37 | stat "local"
namelist '=' explist
38 | stat "do"
block_ended
40 | stat "yield"
args
41 | stat "yield";
43 if_unmatched: if_unmatched
"elseif" if_unmatched
44 | exp
"then" chunk;
46 varlist: varlist ','
var
47 |
var;
48 bracket: '(' exp ')'
49 var: Name
50 | "self"
51 | bracket
var_omega
52 | var var_omega
53 | function_call var_omega;
54 var_omega: '[' exp
']'
55 |
": identifier"; // Lua: ('.' Name) / (':' Name), Lua5L:
Name:Name.Name <- may be
56 function_call: bracket
args
57
| var args
58
| function_call args;
59 args: '(' explist
')'
60 | '(' ')'
61 | '{' fieldlist '}'
62 | '{' '}'
63
| String
64 | "`[integral
const]`"
65 | "`[const object]`"; //
nil, false, true, number
66 explist: explist ','
exp
67 |
exp;
68 exp: _expression_
70 | exp '`' var '`' exp /* 0 */ // Lua: var '('
exp ',' exp ')'
71 | exp "`or`" exp /* 1
*/
72 | exp "`xor`" exp /* 1
*/
73 | exp "`and`" exp; /* 2 */
74 _expression_: _expression_ "`==`"
_expression_ /* 3, %nonassoc */
75 | _expression_
"`~=`" _expression_ /* 3, %nonassoc */
76 | _expression_
'>' _expression_ /* 3, %nonassoc */
77 | _expression_
'<' _expression_ /* 3, %nonassoc */
78 | _expression_
"`<=`" _expression_ /* 3, %nonassoc */
79 | _expression_
"`>=`" _expression_ /* 3, %nonassoc */
80 | _expression_
"`..`" _expression_ /* 4, %right */
81 | _expression_ '+'
_expression_ /* 5 */
82 | _expression_ '-'
_expression_ /* 5 */
83 | _expression_ '*'
_expression_ /* 6 */
84 | _expression_ '/'
_expression_ /* 6 */
85 | _expression_ '%'
_expression_ /* 6 */
86 | '-' _expression_
/* 7 */
87 | '+' _expression_
/* 7 */
88 | '!' _expression_
/* 7 */
89 | _expression_ '^'
_expression_ /* 8,%right */
90 | '$'
_expression_ /* 9 */ // {len} Lua:
#exp
91 |
const_exptession
92 |
function_def
93 |
bracket
94 |
function_call
95 |
var
96 |
"`...`";
97 const_exptession: '{' fieldlist
'}'
98
| '{' '}'
99
| String
100
| "`[integral const]`"
101
| "`[const object]`";
102 fieldlist: fieldlist
',' fieldlist
103 | '[' exp ']' '='
exp
104 | Name
'=' exp
105 |
exp;
A rhetorical question about: is it really necessary? - not accept. Its
longe, boring question, and not rhetorical answer.
The
question: Have You interesting idea about Lua
syntax?
PS:
PEG released, its no
problem.