summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/mylang.ebnf24
1 files changed, 12 insertions, 12 deletions
diff --git a/doc/mylang.ebnf b/doc/mylang.ebnf
index 0ab786d..7c67bbb 100644
--- a/doc/mylang.ebnf
+++ b/doc/mylang.ebnf
@@ -8,25 +8,25 @@ nl = "\n".
ident = letter { letter | digit }.
integer = digit { digit }.
-bool = bool "||" join | join.
-join = join "&&" equality | equality.
-equality = equality "==" relation | equality "!=" relation | relation.
-relation = expression "<" expression | expression "<=" expression | expression ">=" expression | expression ">" expression | expression.
-expression = expression "+" term | expression "-" term | term.
-term = term "*" unary | term "/" unary | term "%" unary | unary.
-unary = "!" unary | "-" unary | factor.
-factor = "(" bool ")" | ident | integer | "true" | "false".
+disjunction = conjunction { "||" conjunction }.
+conjunction = boolean { "&&" boolean }.
+boolean = "!" disjunction | comparison | "(" disjunction ")" | "true" | "false".
+comparison = expression ( "==" | "!=" | "<" | "<=" | "=>" | ">" ) expression.
+
+expression = term { ( "+" | "-" ) term }.
+term = unary { ( "*" | "/" | "%" ) unary }.
+unary = ident | integer | "-" unary | "(" expression ")".
ident_list = ident { "," ident }.
expression_list = expression { "," expression }.
-function_list = function { [ nl ] function }.
+function_list = function { nl function }.
statement_list = statement { nl statement }.
-function = "fun" ident "[" [ ident_list ] "]" [ nl ] statement_list [ nl ] "end".
+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".
+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 ] "]".