summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/mylang.ebnf36
1 files changed, 18 insertions, 18 deletions
diff --git a/doc/mylang.ebnf b/doc/mylang.ebnf
index 7c67bbb..f84869f 100644
--- a/doc/mylang.ebnf
+++ b/doc/mylang.ebnf
@@ -8,27 +8,27 @@ nl = "\n".
ident = letter { letter | digit }.
integer = digit { digit }.
-disjunction = conjunction { "||" conjunction }.
-conjunction = boolean { "&&" boolean }.
-boolean = "!" disjunction | comparison | "(" disjunction ")" | "true" | "false".
-comparison = expression ( "==" | "!=" | "<" | "<=" | "=>" | ">" ) expression.
-
+boolean = join { "||" join }.
+join = relation { "&&" relation }.
+relation = expression { ( "==" | "!=" | "<" | "<=" | ">=" | ">" ) expression }.
expression = term { ( "+" | "-" ) term }.
term = unary { ( "*" | "/" | "%" ) unary }.
-unary = ident | integer | "-" unary | "(" expression ")".
+unary = "!" unary | "-" unary | factor.
+factor = "(" boolean ")" | ident | integer | "true" | "false" | function_call.
+
+function_call = "call" ident "[" [ expression_list ] "]".
ident_list = ident { "," ident }.
-expression_list = expression { "," expression }.
-function_list = function { nl function }.
-statement_list = statement { nl statement }.
-
-function = "fun" ident "[" [ ident_list ] "]" nl statement_list nl "end".
-statement = [ if_statement | while_statement | assign_statement | function_call | return_statement ].
-
-if_statement = "if" expression nl statement_list nl [ "else" statement_list nl ] "end".
-while_statement = "while" expression nl statement_list nl "end".
-return_statement = "@" expression.
-assign_statement = ident "=" expression.
-function_call = ident "[" [ expression_list ] "]".
+expression_list = boolean { "," boolean }.
+function_list = function { function }.
+statement_list = statement { statement }.
+
+function = "fun" ident "[" [ ident_list ] "]" nl statement_list "end" nl.
+statement = ( if_statement | while_statement | assign_statement | return_statement | function_call ).
+
+if_statement = "if" boolean nl statement_list [ "else" nl statement_list ] "end" nl.
+while_statement = "while" boolean nl statement_list "end" nl.
+return_statement = "@" boolean nl.
+assign_statement = ident "=" boolean nl.
program = function_list.