From 4aedc5d76250fae734af1cd89256ec70e165ab18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Mon, 29 Jun 2009 12:28:01 +0200 Subject: fix function_call - function_call is now an expression and a statement - call keyword is required to make lookahead = 1 work --- doc/mylang.ebnf | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'doc') 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. -- cgit v1.2.3