From: "Carlos Maniero" <carlos@maniero.me>
To: "Johnny Richard" <johnny@johnnyrichard.com>,
<~johnnyrichard/olang-devel@lists.sr.ht>
Cc: "Ricardo Kagawa" <ricardo_kagawa@disroot.org>
Subject: Re: [PATCH olang v1] spec: ebnf: add binary expressions
Date: Tue, 16 Apr 2024 00:33:58 -0300 [thread overview]
Message-ID: <D0L8C9D5VDC0.2OJQ38T0HUJMP@maniero.me> (raw)
In-Reply-To: <20240415184116.140292-1-johnny@johnnyrichard.com>
> (* Expressions *)
> -<expression> ::= <integer> | <identifier>
> +<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>
> + | <identifier>
> + | '(' <ows> <expression> <ows> ')'
I'd like to get your opinion: Is it really necessary to represent
precedence here? Some language specifications [1] chose to omit this
detail. I' more inclined to keep the spec as simple as possible, even if
it makes the behavior a bit unclear. I believe it's more important to
represent our grammar in the spec rather than precisely detail how
olang behaves. Alternatively, we could follow Go's approach; they kept
the spec simple and added explanatory text about the language's
behavior.
But again, I just wanna an opinion here, I'm totally OK following the
spec you wrote, because I know that I suck at understanding the
precedence climbing method. :-)
[1]: Golang EBNF: https://go.dev/ref/spec#Expression / Rust EBNF:
https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/grammar.html#binary-operator-expressions
next prev parent reply other threads:[~2024-04-16 3:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 18:20 Johnny Richard
2024-04-15 17:43 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-04-16 3:33 ` Carlos Maniero [this message]
2024-04-16 19:20 ` [PATCH olang v1] spec: ebnf: add binary expressions Johnny Richard
2024-04-16 23:17 ` ricardo_kagawa
2024-04-18 23:17 ` Johnny Richard
2024-04-16 23:41 ` Johnny Richard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D0L8C9D5VDC0.2OJQ38T0HUJMP@maniero.me \
--to=carlos@maniero.me \
--cc=johnny@johnnyrichard.com \
--cc=ricardo_kagawa@disroot.org \
--cc=~johnnyrichard/olang-devel@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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