aboutsummaryrefslogtreecommitdiff
path: root/documentation
diff options
context:
space:
mode:
authorCody <cody@codyq.dev>2023-04-08 14:46:57 -0500
committerCody <cody@codyq.dev>2023-04-08 14:46:57 -0500
commitac7d2a187bff55ddda5e22e1cbda1090ff8d0a1f (patch)
tree7b04e6b20dff06e69b35a10788e0c12c8d89fc45 /documentation
parent6e218c3fcde07f7b6c3111a8d6d915bc9292e07e (diff)
downloadsloth-ac7d2a187bff55ddda5e22e1cbda1090ff8d0a1f.tar.gz
Progress
Diffstat (limited to 'documentation')
-rw-r--r--documentation/grammar.txt57
-rw-r--r--documentation/order.txt18
2 files changed, 75 insertions, 0 deletions
diff --git a/documentation/grammar.txt b/documentation/grammar.txt
new file mode 100644
index 0000000..1217751
--- /dev/null
+++ b/documentation/grammar.txt
@@ -0,0 +1,57 @@
+### Statements
+
+expr_statment : expression ( ";" | "\n" )
+
+### Expressions
+
+expression : logical_or
+
+### Operators
+
+logical_or : logical_and ( "||" logical_and )*
+logical_and : equality ( "&&" equality )*
+
+equality : comparison ( ( "==" | "!=" ) comparison )*
+comparison : bitwise_or ( ( "<=" | ">=" | "<" | ">" ) bitwise_or )*
+
+bitwise_or : bitwise_xor ( "|" bitwise_xor )*
+bitwise_xor : bitwise_and ( "^" bitwise_and )*
+bitwise_and : bitwise_shift ( "&" bitwise_shift )*
+bitwise_shift : additive ( ( "<<" | ">>" ) additive )*
+
+additive : multiplicative ( ( "+" | "++" | "-" ) multiplicative )*
+multiplicative : unary ( ( "*" | "**" | "/" | "%" ) unary )*
+unary : ( "!" | "-" | "~" ) unary | call
+
+call : primary ( "(" ( primary "," )* primary? ")" )*
+
+primary : identifier
+ | literal
+ | "(" expression ")"
+
+### Types
+
+identifier : ( ALPHA | "_" | "$" ) ( ALPHANUMERIC | "_" | "$" )*
+literal : string
+ | char
+ | float
+ | int
+ | boolean
+
+string : '"' ALPHANUMERIC* '"'
+char : "'" ALPHANUMERIC "'"
+float : NUMERIC "." NUMERIC*
+int : NUMERIC+
+boolean : "true" | "false"
+
+### Primitives
+
+ALPHANUMERIC = ALPHA | NUMERIC
+NUMERIC = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
+ALPHA = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J"
+ | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T"
+ | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d"
+ | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n"
+ | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x"
+ | "y" | "z"
+
diff --git a/documentation/order.txt b/documentation/order.txt
new file mode 100644
index 0000000..8727306
--- /dev/null
+++ b/documentation/order.txt
@@ -0,0 +1,18 @@
+| Name | Operators | Associates |
+| -------------- | --------- | ---------- |
+| parentheses | () | Left |
+| member access | . ! !! ?. | Left |
+| defaulting | ?: | Right |
+| function call | () | Left |
+| unary | ! - ~ | Right |
+| multiplicative | * / % | Left |
+| additive | + - | Left |
+| bitwise shift | << >> | Left |
+| comparison | < > <= >= | Left |
+| equality | == != | Left |
+| bitwise and | & | Left |
+| bitwise xor | ^ | Left |
+| bitwise or | | | Left |
+| logical and | && | Left |
+| logical or | || | Left |
+