Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compound grammar

4 views
Skip to first unread message

Jonathan Lang

unread,
Mar 5, 2007, 12:25:31 AM3/5/07
to p6l
AFAICT, there's nothing in the documentation to explain how one would
define a statement or operator with syntax along the lines of "if ...
else ..." or "... ?? ... :: ..." Admittedly, the only cases I know of
where this is still an issue are the two listed above: for statements,
all other perl 5 parallels have been replaced by the use of closure
traits; and the operator listed above is the only more-than-binary
operator that I've ever heard of which uses different delimiters.
That said, for the sake of future customization, it would be nice to
have a way to do these things. (Or is this what macros are for?)

In the latter case, I find myself thinking about expanding on
"infix:<>" to allow for a list of tokens, much like "circumfix:<>"
does:

infix:<?? ::> ($condition, $true, $false) #< $condition ?? $true :: $false >

...and I'm wondering if something like this could be done in the
former case as well:

statement_control:<if else> ($condition, &true, &false?) #< if
$condition { ... } else { ... } >

Although this wouldn't cleanly handle an "if ... elsif ... elsif ...
else ..." statement.

--
Jonathan "Dataweaver" Lang

Larry Wall

unread,
Mar 5, 2007, 12:38:05 AM3/5/07
to p6l
On Sun, Mar 04, 2007 at 09:25:31PM -0800, Jonathan Lang wrote:
: AFAICT, there's nothing in the documentation to explain how one would

Please see http://svn.pugscode.org/pugs/src/perl6/Perl-6.0.0-STD.pm for
the current definitions of those syntactic constructs. The point of
doing grammars the way we're doing is to allow you to derive from this
grammar and override the rules as you see fit. Macros and user-defined
are just convenient ways to define bits of grammar without actually
adding or modifying any rules, at least not overtly.

Larry

Larry Wall

unread,
Mar 5, 2007, 12:40:17 AM3/5/07
to p6l
On Sun, Mar 04, 2007 at 09:38:05PM -0800, Larry Wall wrote:
: grammar and override the rules as you see fit. Macros and user-defined

s/user-defined/user-defined operators/

Larry

0 new messages