[antlr-interest] Problem finding Template

Jim Idle jimi at intersystems.com
Fri Jan 26 10:53:40 PST 2007


The construct in your grammar is causing ANTLR to generate a reference to a template the does not exist in the codegen .st file. This is either erroneous or perhaps it is one of a missing few templates that Ter has not covered and so neither have the other targets (yet). I think that there are some comments in the c.st file about this, saying that there are going to have to be templates that track and label, or something similar.

I hitnk that this:

term :    (ID^^|lp=INT -> ^(KK[$lp] INT)| '('! logicalExpression^^  
> ')'!);

is "probably" what is causing it. The ID^^ without a label and lp=INT at the same time, but this is a bit of a guess to be honest. You could try rearranging this a little and you might be able to get it to go away:

term
	: ID					-> ID
	| INT					-> ^(KP INT)
	| '(' logicalExpresssion ')'	-> logicalExpression
	;

Or perhaps:

term
	: ( id=ID					-> $id				)
	| ( in=INT					-> ^(KP[$in.text] $in)		)
	| ( '(' le=logicalExpresssion ')'	-> $le				)
	;

But it will take a little experimentation. ANTLR 3 is still beta and there are a few quirks to iron out yet as you might expect.

Jim

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Dr. Kocher, Hartmut
Sent: Friday, January 26, 2007 12:36 AM
To: Terence Parr; ANTLR List
Subject: [antlr-interest] Problem finding Template

I'll try this solution. How does the label help here?

I cannot use the pre-beta as it doesn't generate C# code yet (some templates seem to have changed and StringTemplates complains that the C#-template does not match the interface).

But I still don't quite understand: ANTLR tries to load a template which obviously isn't there. So either you have to include that template or you must change the part, which uses the template... Or am I missing something?

Thanks
Hartmut

-----Ursprüngliche Nachricht-----
Von: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] Im Auftrag von Terence Parr
Gesendet: Freitag, 26. Januar 2007 00:26
An: ANTLR List
Betreff: Re: [antlr-interest] Problem finding Template

Hi.  I think ID^^ is the problem, but not sure why... seems it  
doesn't like it for some reason.  Hmm...try 3.0 pre-b6 from site, but  
you can try using a label on any token^^ to avoid I think.
Ter

On Jan 25, 2007, at 3:22 PM, Dr. Hartmut Kocher wrote:

> Hi,
>
>
>
> using ANTLR 3.0B5, I get an exception when I parse my grammar: error 
> (10):  internal error: Test.g : java.lang.IllegalArgumentException:  
> Can't find template tokenRefRuleRootTrack.st
>
>
>
> Has anybody encountered this?
>
>
>
> Here's a simple grammar to show the effect:
>
>
>
> Thanks.
>
>
>
> grammar Test;
>
>
>
> options {
>
>      language=CSharp;
>
>      output=AST;
>
>      ASTLabelType=CommonTree;
>
> }
>
>
>
> tokens { KK; }
>
>
>
> logic     :    logicalExpression EOF;
>
>
>
> logicalExpression    :    expr ('and'^^ expr)*;
>
>
>
> expr :    term ('or'^^ term)*;
>
>
>
> term :    (ID^^|lp=INT -> ^(KK[$lp] INT)| '('! logicalExpression^^  
> ')'!);
>
>
>
> zahl :lp=INT -> ^(KK[$lp] INT);
>
>
>
> fragment DIGIT  :    '0'..'9';
>
>
>
> fragment LETTER :    ('a'..'z'|'A'..'Z');
>
>
>
> INT :    DIGIT+;
>
>
>
> ID   :    LETTER (LETTER|'_'|DIGIT)+;
>
>
>
>
>
> WS  :  (' '|'\r'|'\t'|'\f'|'\n')+ { $channel=HIDDEN; };
>
>
>
> SL_COMMENT :
>
>         '//'
>
>         ( options { greedy=false; } : . )*
>
>         ( '\r' | '\r\n' | '\n' )
>
>         { $channel=HIDDEN; }
>
>     ;
>
>
>
> // multiple-line comments
>
> ML_COMMENT :
>
>         '/*'
>
>         ( options {greedy=false;} : . )*
>
>         '*/'
>
>         { $channel=HIDDEN; }
>
>         ;
>
>
>
>
>
>
>
> Dr. Hartmut Kocher
>
> Cortex Brainware Consulting & Training GmbH
>
> Kirchplatz 5
> D-82049 Pullach
>
> Tel: +49 (89) 744  850 0
> Fax: +49 (89) 744  850 11
>
> http://www.cortex-brainware.de
>
> E-Mail: hwk at cortex-brainware.de
>
> Handelsregister:
> Registergericht: Amtsgericht München
> HRB-Nr. 120614
>
> Vertretungsberechtigte Geschäftsführer:
> Dipl.-Inform. Dorothea Burger, Dr.-Ing. Hartmut Kocher, Dr.-Ing.  
> Martin Lang, Dr. rer. nat. Rolf Peter Wehrum
>
>
>
>


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007 3:32 PM
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007 3:32 PM
 


More information about the antlr-interest mailing list