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

Micheal J open.zone at virgin.net
Sat Apr 12 10:27:04 PDT 2008


Hi,
 
Not quite. The only distinction is between the "Combined" grammar type
(lexer + parser in same file) and other grammar types (lexer, parser or
treeparser only in file)
 
- In combined grammars the prefixed forms '@lexer::namespace' and
'@parser::namespace' <mailto:'@parser::'>  are used to distinguish between
blocks specific to either lexer or parser but, '@namespace' applies to the
parser part only [1*],
 
- In other grammars (i.e. non-combined grammars) no distinction is needed.
 
 
Micheal
 
-----------------------
The best way to contact me is via the list/forum. My time is very limited. 

 
[1*]   The counter-inuitive scheme survives due to Ter iirc. Others had
suggested that blocks without  '@lexer::' or '@parser::' prefixes in
combined grammars should apply to both lexers and parsers. Had that been the
case,  '@namespace' would have worked in all grammar types. I don't hold out
much hope that Ter would make this change (or indeed accept a patch that
did).  


  _____  

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Eamon Nerbonne
Sent: 12 April 2008 17:48
To: Jim Idle
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] tree grammar namespace option for CSharp
target


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#Antlr3CSharpT
arget-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/a5f8b464/attachment-0001.html 


More information about the antlr-interest mailing list