[antlr-interest] tree grammar namespace option for CSharp target

Eamon Nerbonne eamon at nerbonne.org
Sat Apr 12 09:48:08 PDT 2008


After some experimentation then:

@lexer::namespace specifies the namespace for lexers,
@parser::namespace specifies the namespace for non-tree parsers
@namespace specifies the namespace for both tree and non-tree parsers.

I've updated the wiki accordingly.  This particular naming scheme does not,
however, seem very consistent atm.  Will antlr 3.1 and beyond's C# target
merge tree and non-tree parsers and thus remove the current distinction?

On Wed, Apr 9, 2008 at 10:06 PM, Jim Idle <jimi at temporal-wave.com> wrote:

>  I should clarify:
>
>
>
> @namespace { }
>
>
>
> Is what it should be I think.
>
>
>
> Jim
>
>
>
> *From:* antlr-interest-bounces at antlr.org [mailto:
> antlr-interest-bounces at antlr.org] *On Behalf Of *Jim Idle
> *Sent:* Wednesday, April 09, 2008 1:04 PM
> *To:* antlr-interest at antlr.org
> *Subject:* Re: [antlr-interest] tree grammar namespace option for CSharp
> target
>
>
>
> Don't remove the tree part, but do remove the @parser:: part and you
> should find that it works :-)
>
>
>
> Jim
>
>
>
> *From:* antlr-interest-bounces at antlr.org [mailto:
> antlr-interest-bounces at antlr.org] *On Behalf Of *Eamon Nerbonne
> *Sent:* Wednesday, April 09, 2008 12:43 PM
> *To:* antlr-interest at antlr.org
> *Subject:* [antlr-interest] tree grammar namespace option for CSharp
> target
>
>
>
> Using C# + ANTLR 3.0.1 (antlrworks 1.1.7), I'd like to place the generated
> tree grammar parser in a namespace.  The wiki-docs explain how to do this
> for parsers and lexers, but these commands don't work in tree grammars.
>
> The antlr wiki-docs are at
> http://www.antlr.org/wiki/display/ANTLR3/Antlr+3+CSharp+Target#Antlr3CSharpTarget-Specifyingthenamespaceforyourrecognizer
> The (simple) grammar which triggers this is attached, but the problematic
> combination is simply:
>
> *tree *grammar ModalFormulaTree;
>
> options {
>     language=CSharp;
>     tokenVocab=ModalFormulaParser;
> }
>
> @parser::namespace { FormulaParser.Generated }
>
> Notably, removing the "tree" from the first line still generates a tree
> grammar and no longer complains about an "unknown or invalid action scope
> for tree grammar: parser", but the resultant tree grammar is not placed in a
> namespace tag.
>
> Is there a different option for tree grammars - or is this a bug?
>



-- 
eamon at nerbonne.org - Tel#:+31-6-15142163
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080412/d65862e3/attachment.html 


More information about the antlr-interest mailing list