You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common pattern in rust-peg grammars is to use a block at the end of a parenthesized subexpression to choose a return value inside of a * or ? expression, for example when handling an optional type after a Rust-style let expression:
"let" name:ident() ty:(":" t:type_expr() { t })?
This requires introducing an extra variable t and a lot of noise just to pick out the part of the expression you want to return.
This proposes a syntactic sugar
"let" name:ident() ty:(":" :type_expr())?
to allow :-tagged arguments without labels and without an action block, where the sequence would evaluate to the tagged labels.
This could also build a tuple if there are multiple, making (:x(), :y()) equivalent to (a:x() b:y() {(a, b)}).
I think the :expr syntax is unambiguous now that parentheses are required on rule invocations, but will need to verify. It requires a little bit of lookahead and may be confusing for humans as well. >:expr or ^:expr could be alternatives, but PEG is already quite symbol-heavy.
The text was updated successfully, but these errors were encountered:
If @ symbol is not used (it seems so) then I think it is good alternative which is notisable enough without creating too much visual noise. That symbol is used in peggyjs. Using : too noisy at my glance.
A common pattern in rust-peg grammars is to use a block at the end of a parenthesized subexpression to choose a return value inside of a
*
or?
expression, for example when handling an optional type after a Rust-stylelet
expression:This requires introducing an extra variable
t
and a lot of noise just to pick out the part of the expression you want to return.This proposes a syntactic sugar
to allow
:
-tagged arguments without labels and without an action block, where the sequence would evaluate to the tagged labels.This could also build a tuple if there are multiple, making
(:x(), :y())
equivalent to(a:x() b:y() {(a, b)})
.I think the
:expr
syntax is unambiguous now that parentheses are required on rule invocations, but will need to verify. It requires a little bit of lookahead and may be confusing for humans as well.>:expr
or^:expr
could be alternatives, but PEG is already quite symbol-heavy.The text was updated successfully, but these errors were encountered: