* [PATCH olang v2] docs: spec: add binary expressions
@ 2024-04-16 23:35 Johnny Richard
2024-04-16 22:40 ` [olang/patches/.build.yml] build success builds.sr.ht
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Johnny Richard @ 2024-04-16 23:35 UTC (permalink / raw)
To: ~johnnyrichard/olang-devel; +Cc: Johnny Richard, Ricardo Kagawa
The parser already implements binary operations, but currently we are
missing it on the language specification.
This change adds the already implemented binary operations grammar and
also enables expression with parenthesis.
It's important to mention that the precedence was highly inspired on C.
Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
---
v1 -> v2: rebase on current main branch.
docs/pages/language-specification.md | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/docs/pages/language-specification.md b/docs/pages/language-specification.md
index 3cf050e..a9931c1 100644
--- a/docs/pages/language-specification.md
+++ b/docs/pages/language-specification.md
@@ -50,7 +50,21 @@ language.
<assignment-operator> ::= '='
(* Expressions *)
-<expression> ::= <integer-literal> | <variable-name>
+<expression> ::= <binary-expression>
+<binary-expression> ::= <logical-or-expression>
+<logical-or-expression> ::= <logical-and-expression> (<ows> '||' <ows> <logical-and-expression>)*
+<logical-and-expression> ::= <bitwise-or-expression> (<ows> '&&' <ows> <bitwise-or-expression>)*
+<bitwise-or-expression> ::= <bitwise-xor-expression> (<ows> '|' <ows> <bitwise-xor-expression>)*
+<bitwise-xor-expression> ::= <bitwise-and-expression> (<ows> '^' <ows> <bitwise-and-expression>)*
+<bitwise-and-expression> ::= <cmp-eq-and-neq-expression> (<ows> '&' <ows> <cmp-eq-and-neq-expression>)*
+<cmp-eq-and-neq-expression> ::= <cmp-lt-and-gt-expression> (<ows> ('==' | '!=') <ows> <cmp-lt-and-gt-expression>)*
+<cmp-lt-and-gt-expression> ::= <bitwise-shift-expression> (<ows> ('<' | '>') <ows> <bitwise-shift-expression>)*
+<bitwise-shift-expression> ::= <additive-expression> (<ows> ('<<' | '>>') <ows> <additive-expression>)*
+<additive-expression> ::= <multiplicative-expression> (<ows> ('+' | '-') <ows> <multiplicative-expression>)*
+<multiplicative-expression> ::= <primary-expression> (<ows> ('*' | '/') <ows> <primary-expression>)*
+<primary-expression> ::= <integer-literal>
+ | <variable-name>
+ | '(' <ows> <expression> <ows> ')'
(* Identifiers *)
<type> ::= 'u32'
base-commit: 00469200f51f96921d31310af587a1f5b808d87a --
2.44.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-16 22:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 23:35 [PATCH olang v2] docs: spec: add binary expressions Johnny Richard
2024-04-16 22:40 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-04-16 22:45 ` [PATCH olang v2] docs: spec: add binary expressions Carlos Maniero
2024-04-16 23:47 ` Johnny Richard
Code repositories for project(s) associated with this public inbox
https://git.johnnyrichard.com/olang.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox