From a1cc04575c037b8411e9720088e7cd5cc2ffc505 Mon Sep 17 00:00:00 2001 From: Funky Waddle Date: Fri, 28 Nov 2025 03:28:36 -0600 Subject: [PATCH] Implement proper whitespace functionality. Implement single line and multi line comments --- grammar/core/base_types.bnf | 2 +- grammar/core/comments.bnf | 11 +++++ grammar/core/identifiers.bnf | 9 +++- grammar/core/keywords.bnf | 6 +++ .../declarations/function_declarations.bnf | 43 ++++++++++++------- grammar/declarations/type_declarations.bnf | 34 ++++++++++----- grammar/main.bnf | 20 ++++++--- grammar/operations/control_flow.bnf | 41 ++++++++++++++++-- grammar/operations/expressions.bnf | 26 +++++++---- 9 files changed, 145 insertions(+), 47 deletions(-) create mode 100644 grammar/core/comments.bnf diff --git a/grammar/core/base_types.bnf b/grammar/core/base_types.bnf index a43fcd9..98eacf6 100644 --- a/grammar/core/base_types.bnf +++ b/grammar/core/base_types.bnf @@ -9,4 +9,4 @@ | | "Any" - ::= "[" ("," )* "]" | + ::= "[" ( "," )* "]" | diff --git a/grammar/core/comments.bnf b/grammar/core/comments.bnf new file mode 100644 index 0000000..2902644 --- /dev/null +++ b/grammar/core/comments.bnf @@ -0,0 +1,11 @@ + ::= | + + ::= * + + ::= + ( | )* + + + ::= | | | + + ::= | | | diff --git a/grammar/core/identifiers.bnf b/grammar/core/identifiers.bnf index 3551ccc..8325013 100644 --- a/grammar/core/identifiers.bnf +++ b/grammar/core/identifiers.bnf @@ -16,5 +16,12 @@ ::= "!" | "@" | "#" | "$" | "%" | "^" | "&" | "*" | "(" | ")" | "-" | "_" | "+" | "=" | "[" | "]" | "{" | "}" | "|" | "\" | ":" | ";" | "<" | ">" | "," | "." | "?" | "/" - ::= " " | "\t" | "\n" | "\r" + ::= | | + ::= " " | "\t" + + ::= "\n" | "\r" + + ::= * + + | )* \ No newline at end of file diff --git a/grammar/core/keywords.bnf b/grammar/core/keywords.bnf index 54366f2..fde281a 100644 --- a/grammar/core/keywords.bnf +++ b/grammar/core/keywords.bnf @@ -2,6 +2,12 @@ ::= "->" + ::= "//" + + ::= "/*" + + ::= "*/" + ::= "String" ::= "Integer" diff --git a/grammar/declarations/function_declarations.bnf b/grammar/declarations/function_declarations.bnf index 264a36a..f601983 100644 --- a/grammar/declarations/function_declarations.bnf +++ b/grammar/declarations/function_declarations.bnf @@ -1,7 +1,16 @@ - ::= - - ( )? - "{" * "}" + ::= + + + + + + + + "{" + + * + + "}" ::= "(" ? ")" @@ -10,26 +19,28 @@ ::= ("/" )? - ::= - ? + ::= ? - ::= - + ::= + ( | "," - | + | ) + ::= - - | "," + + ( + | "," ) ::= - - | "," + + ( + | "," ) ::= ::= ".default(" ")" - ::= "(" ? ")" - "[" "]" - "{" * "}" + ::= "(" ? ")" + "[" "]" + "{" * "}" diff --git a/grammar/declarations/type_declarations.bnf b/grammar/declarations/type_declarations.bnf index fecf5fe..ac13062 100644 --- a/grammar/declarations/type_declarations.bnf +++ b/grammar/declarations/type_declarations.bnf @@ -1,12 +1,21 @@ - ::= - ? - "{" "}" + ::= + + ? + + "{" + + + + "}" - ::= ( - | - | - | - | )* + ::= + ( + | + | + | + | + | )* + ::= ( "/")? @@ -16,8 +25,13 @@ ::= ("," )* - ::= - (".set(" ")")? ";" + ::= + + + + (".set(" ")")? + + ";" ::= ".define(" ");" diff --git a/grammar/main.bnf b/grammar/main.bnf index 8c09f7b..9e4d126 100644 --- a/grammar/main.bnf +++ b/grammar/main.bnf @@ -1,13 +1,21 @@ - ::= * * + ::= * + + * + - ::= ("." )* ";" + ::= + + + ("." )* + ";" - ::= - - | - | + ::= ( + | + | ) + import "core/keywords.bnf" +import "core/comments.bnf" import "core/base_types.bnf" import "core/identifiers.bnf" import "core/literals.bnf" diff --git a/grammar/operations/control_flow.bnf b/grammar/operations/control_flow.bnf index e3d34f1..d162214 100644 --- a/grammar/operations/control_flow.bnf +++ b/grammar/operations/control_flow.bnf @@ -9,12 +9,45 @@ | | + ::= + ( + | + | + | + | + | + | + | + | + | ) + + ::= ".set(" ")" ";" - ::= "(" ")" - "{" * "}" - ( "(" ")" "{" * "}")? - ( "{" * "}")? + ::= + + "(" + + + ")" + "{" * "}" + ( + + "(" + + + + ")" + "{" + * + "}" + )? + ( + + "{" + * + "}" + )? ::= "(" ")" "{" * "}" diff --git a/grammar/operations/expressions.bnf b/grammar/operations/expressions.bnf index 2231967..e22e084 100644 --- a/grammar/operations/expressions.bnf +++ b/grammar/operations/expressions.bnf @@ -1,14 +1,20 @@ - ::= - | - | - | - | - | "(" ")" - | + ::= + ( + + | + | + | + | + | "(" ")" + | + ) + - ::= ".as(" ")" + ::= ".as(" ")" - ::= + ::= + + ( | "(" ")" | ".eq(" ")" @@ -29,4 +35,6 @@ | ".lt(" "," ")" | ".gte(" "," ")" | ".lte(" "," ")" + ) +