[antlr-interest] C++ grammar - namespaces

Matt Benson gudnabrsam at yahoo.com
Wed Mar 5 08:16:45 PST 2003


Hmmm... I went to the Antlr site, then went to
resources and grammars and found it immediately.

--- David Wigg <wiggjd at sbu.ac.uk> wrote:
> Thanks for loading my updated version of a C++
> grammar onto 
> http://www.antlr.org/grammars.
> 
> However, I only found it there by an act of
> serendipty. I can't 
> see how to get there from http://www.antlr.org or
> anywhere else 
> for that matter, or am I missing something?
> 
> I am still working on this grammar making
> significant 
> improvements to bring it up to date.
> 
> 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?
> 
> David.
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/ 
> 
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list