From c813b8317bfb34d8f5f0805c8885f37697af1de8 Mon Sep 17 00:00:00 2001
From: ahmedsamyh <ahmedsamyh10@gmail.com>
Date: Sat, 29 Mar 2025 19:26:28 +0500
Subject: [PATCH] [grammar.txt] Add test grammar for Lox.

---
 grammar.txt | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 grammar.txt

diff --git a/grammar.txt b/grammar.txt
new file mode 100644
index 0000000..056d114
--- /dev/null
+++ b/grammar.txt
@@ -0,0 +1,35 @@
+expression -> literal | unary | binary | grouping ;
+grouping   -> "(" expression ")" ;
+literal    -> NUMBER | STRING | "true" | "false" | "nil" ;
+unary      -> ( "!" | "-" ) expression ;
+binary     -> expression operator expression ;
+operator   -> "==" | "!=" | "<" | "<=" | ">" | ">=" |
+              "+" | "-" | "*" | "/" ;
+
+
+NUMBER     -> "[0-9]" "."? "[0-9]" ;
+STRING     -> \" "[a-zA-Z]"* \" ;
+
+
+So expression could be:
+1. 
+	unary =>
+	!expression =>
+	!literal =>
+	!NUMBER =>
+	!4
+
+2.
+	grouping =>
+	(expression) =>
+	(binary) =>
+	(expression operator expression) =>
+	(literal operator expression) =>
+	(NUMBER operator expression) => 
+	(5.8 operator expression) =>
+	(5.8 * expression) =>
+	(5.8 * unary) =>
+	(5.8 * -expression) =>
+	(5.8 * -literal) =>
+	(5.8 * -NUMBER) =>
+	(5.8 * -8)
-- 
2.39.5