[antlr-interest] C++ grammar - namespaces
Terence Parr
parrt at jguru.com
Wed Mar 5 10:26:57 PST 2003
On Wednesday, March 5, 2003, at 05:44 AM, David Wigg wrote:
> In particular I hope I have now accounted for "namespaces" as
> described on pages 634-638 in the Second Edition of Bjarne
> Stroustrup's book, The C++ Programming Language, as follows,
>
> decl_namespace // alternative in external-declaration
> :
> "namespace"
> (
> (ns:ID{_sc = scTYPEDEF;
> declaratorID((ns->getText()).data());}
> )?
> LCURLY (external_declaration)* RCURLY
> |
> ASSIGNEQUAL qualified_id SEMICOLON {end_of_stmt();}
> )
> ;
>
> using_statement // alternative in declaration
> :
> "using"
> (
> "namespace" qualified_id // Using-directive
> |
> qualified_id // Using-declaration
> )
> SEMICOLON {end_of_stmt();}
> ;
>
> However, I still have a problem about the correct type for a
> namespace. The parser works on my test data by using
> declaratorId to set it as a 'typedef' but I think it would be
> better classed as 'class' since it introduces a new scope. What
> do you think?
>
> What type should I use Terence?
HI David,
Hmm...well, C++ is not my strong point anymore. I think Ric can have
something to say here.
Terence
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list