From 6c4f39708bfa0c1d8d9afab299ef538c6183204e Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sun, 18 Aug 2024 23:56:26 +0800 Subject: Changed the grammar to allow bare top-level expressions only in REPL. --- grammar.bnf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'grammar.bnf') diff --git a/grammar.bnf b/grammar.bnf index 0ac58f9..a9e21cb 100644 --- a/grammar.bnf +++ b/grammar.bnf @@ -1,7 +1,7 @@ // Comments are introduced by # and terminated by newline program ::= (statement ';'?)*; -statement ::= definition | expression; +statement ::= definition; definition ::= 'def' def-spec '=' expression | 'def' '_' '=' expression; def-spec ::= IDENTIFIER arg-spec*; @@ -31,3 +31,6 @@ let-in-expression ::= 'let' def-spec '=' expression ('and' def-spec '=' expressi fn-expression ::= 'fn' arg-spec+ '->' expression | 'fn' arg-spec+ do-expression; do-expression ::= 'do' expression (';' expression)* 'end'; + +repl-program ::= (repl-statement ';'?)* '\n'; // currently, hard-limited by the newline :sweat_smile: +repl-statement ::= statement | expression; \ No newline at end of file -- cgit v1.2.3