[antlr-interest] Namespaces and generated Antlr classes.

Loring Craymer craymer at warpiv.com
Tue May 30 01:16:16 PDT 2006


In the "options" section of a grammar, insert a line that reads

namespace = "dummy";

and you will get the behavior you want.  (Although you may want some
namespace other than "dummy" ...)

--Loring

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mark Kattenbelt
> Sent: Tuesday, May 30, 2006 12:57 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Namespaces and generated Antlr classes.
> 
> Hi,
> 
> I have a working Lexer/Parser/Treewalker etc. There is one thing bugging
> me though, how do I get the generated classes to be a member of a
> namespace?
> 
> Say I have a dummy.g file which generates a class DummyParser in c++.
> However I would like to make sure this class belongs to namespace dummy
> as dummy::DummyParser.
> 
> Putting this in your .g is not an option:
> 
> header
> {
> namespace dummy
> {
> }
> 
> For obvious reasons.
> 
> Any suggestions?
> 
> Cheers,
> 
> Mark



More information about the antlr-interest mailing list