Skip to content

Commit 8919bb5

Browse files
committed
Update syntax to Lua 5.4
1 parent fa332b9 commit 8919bb5

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

docs/extended_bnf.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@ block = return_statement | statement {statement} [return_statement];
1111
(* statements *)
1212
return_statement = "return" [expression_list] [empty_statement];
1313
14-
statement = do_statement | if_statement | for_numeric_statement
15-
| for_generic_statement | while_statement | repeat_statement | break_statement
16-
| label_statement | goto_statement | variable_assignment
17-
| scoped_variable_declaration | function_declaration | scoped_function_declaration
18-
| function_call | empty_statement;
14+
statement = do_statement | if_statement | for_numeric_statement | for_generic_statement
15+
| while_statement | repeat_statement | break_statement | label_statement | goto_statement
16+
| variable_assignment | scoped_variable_declaration | function_definition_statement
17+
| scoped_function_definition_statement | function_call | empty_statement;
1918
2019
empty_statement = ";";
2120
22-
scoped_function_declaration = "local" "function" identifier function_body;
21+
scoped_function_definition_statement = "local" "function" identifier function_body;
2322
24-
function_declaration = "function" function_identifier function_body;
23+
function_definition_statement = "function" function_identifier function_body;
2524
function_identifier = identifier {"." identifier} [":" identifier];
2625
27-
scoped_variable_declaration = "local" identifier_list ["=" expression_list];
26+
scoped_variable_declaration = "local" scoped_variable_list ["=" expression_list];
27+
scoped_variable_list = scoped_variable {',' scoped_variable};
28+
scoped_variable = identifier [attribute];
29+
attribute = '<' identifier '>';
2830
2931
variable_assignment = variable_list "=" expression_list;
3032
variable_list = variable {"," variable};
@@ -35,24 +37,20 @@ label_statement = "::" identifier "::";
3537
break_statement = "break";
3638
repeat_statement = "repeat" [block] "until" expression;
3739
while_statement = "while" expression "do" [block] "end";
38-
for_generic_statement = "for" identifier_list "in" expression_list
39-
"do" [block] "end";
40-
for_numeric_statement = "for" identifier "=" expression "," expression ["," expression]
41-
"do" [block] "end";
40+
for_generic_statement = "for" identifier_list "in" expression_list "do" [block] "end";
41+
for_numeric_statement = "for" identifier "=" expression "," expression ["," expression] "do" [block] "end";
4242
4343
if_statement = "if" expression "then" [block] {"elseif" expression "then" [block]}
4444
["else" [block]] "end";
4545
4646
do_statement = "do" [block] "end";
4747
4848
(* expressions *)
49-
expression = nil | boolean | number | string | unary_expression
50-
| binary_expression | table | vararg_expression | function_definition
51-
| prefix_expression;
49+
expression = nil | boolean | number | string | unary_expression | binary_expression
50+
| table | vararg_expression | function_definition | prefix_expression;
5251
5352
prefix_expression = variable | function_call | "(" expression ")";
54-
variable = identifier | prefix_expression "." identifier
55-
| prefix_expression "[" expression "]";
53+
variable = identifier | prefix_expression "." identifier | prefix_expression "[" expression "]";
5654
function_call = prefix_expression [":" identifier] argument_list;
5755
argument_list = string | table | "(" [expression_list] ")";
5856
expression_list = expression {"," expression};
@@ -76,8 +74,7 @@ binary_operator = "or" | "and" | "==" | "~=" | "<" | ">" | "<=" | ">=" | "|"
7674
unary_expression = unary_operator expression;
7775
unary_operator = "not" | "#" | "-" | "~";
7876
79-
string = "'" {, inline_character - "'"}, "'"
80-
| '"' {, inline_character - '"'}, '"'
77+
string = "'" {, inline_character - "'"}, "'" | '"' {, inline_character - '"'}, '"'
8178
| multiline_start {, character}, multiline_end;
8279
inline_character = ? any character except a newline ?;
8380
character = ? any character ?;
@@ -106,13 +103,12 @@ identifier = (letter | "_") {, letter | decimal_digit | "_"};
106103
letter = ? case insensitive alphabetic character ?;
107104
108105
(* extras *)
109-
comment = "--" {, inline_character}
110-
| "--", multiline_start {, character}, multiline_end;
106+
comment = "--" {, inline_character} | "--", multiline_start {, character}, multiline_end;
111107
112108
(* "start" and "end" must have the same number of equal signs ("=") *)
113109
multiline_start = "[" {, "="}, "[";
114110
multiline_end = "]" {, "="}, "]";
115111
```
116112

117113
[extended bnf]: https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form
118-
[lua manual]: http://www.lua.org/manual/5.3/manual.html#9
114+
[lua manual]: http://www.lua.org/manual/5.4/manual.html#9

0 commit comments

Comments
 (0)