Boost logo

Boost :

From: joel de guzman (isis-tech_at_[hidden])
Date: 2001-05-31 04:57:45


From: "Vladimir Prus" :

>
> I've just got another idea about Spirits's syntax. Consider grammar in C++
> standard (std::A). It uses "-seq" for repetition (+) and "opt" subscript
for
> optinal constructs. What about adding such syntax to Spirit

The iterator syntax, as it stands, is complete as it is IMO. Adding
another way to do things will give us three ways. I think extensions
such as these are best to be Spirit Directives in the form:

   Directive[ expr ]

Spirit already uses a few of these. Your suggestion could
be included as a "user defined library":

  opt[ expr ]

and

  seq[ expr ]

Clients are free to add user defined Directives and Actions
as they will.

> Rule<> points = Point-seq ; // and similary for opt
>
> I think it is possible to implement it in a few minutes.
>
> Also, what about using "," for sequencing? Was this suggestion considered?

That was suggested a couple of times.
Is it a viable operator for sequencing?
I'm afraid to say...

No. That was documented in the Spirit docs. The problem
is that the comma operator has a very low precedence. even
lower than the =.

I quote:

"N[1] The comma operator as in a, b seems to be a better
candidate, syntax-wise. But then the problem is with its
precedence. It has the lowest precedence in C/C++,
which makes it virtually useless."

I always wished I could use the comma. I did, initially.
But I got bitten when I typed in:

r = a, b | c;

Cheers,
Joel de Guzman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk