From 7a80bb071f2e4bd4b85bb04ece9be880af798c3c Mon Sep 17 00:00:00 2001 From: Nocturn9x Date: Sat, 23 Oct 2021 11:59:42 +0200 Subject: [PATCH] Fixed grammar rule for import statements --- docs/grammar.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/grammar.md b/docs/grammar.md index 64d7e90..115e84f 100644 --- a/docs/grammar.md +++ b/docs/grammar.md @@ -86,7 +86,7 @@ statement → exprStmt | forStmt | ifStmt | returnStmt| whileStmt| blockStm exprStmt → expression ";"; // Any expression followed by a semicolon is technically a statement returnStmt → "return" expression? ";"; // Returns from a function, illegal in top-level code breakStmt → "break" ";"; -importStmt -> ("from" IDENTIFIER)? "import" (IDENTIFIER ("as" IDENTIFIER)? ",") ";"; +importStmt -> ("from" IDENTIFIER)? "import" (IDENTIFIER ("as" IDENTIFIER)? ",")+ ";"; assertStmt → "assert" expression ";"; delStmt → "del" expression ";" continueStmt → "continue" ";"; @@ -96,6 +96,7 @@ whileStmt → "while" "(" expression ")" statement; // While loops run unt forStmt → "for" "(" (varDecl | exprStmt | ";") expression? ";" expression? ")" statement; // C-style for loops // For-each loops iterate over a collection type foreachStmt → "foreach" "(" (IDENTIFIER ":" expression) ")" statement; + // Expressions (rules that produce a value, but also have side effects) expression → assignment; assignment → (call ".")? IDENTIFIER "=" yield; // Assignment is the highest-level expression