[antlr-interest] Can't find template

Joseph joseph at iist.unu.edu
Fri Oct 27 22:36:50 PDT 2006


Dear All,

I am a new user of ANTLR and String Template. I am developing a translator and  
using the example cminus as a starting point. I get the following error which 
i cannot figure out why its there even when the "type_int" is specified in 
the .stg file. 

Could any one help me out.

Here is the error message:

joe at joe:~/utpcompiler/utp2pvs$ java -cp .:antlr-2.7.7.jar:stringtemplate.jar 
UTP < test1.utp
Exception in thread "main" java.lang.IllegalArgumentException: Can't find 
template type_int.st
        at 
org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate(StringTemplateGroup.java:485)
        at 
org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:372)
        at 
org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:384)
        at UTPParser.template(UTPParser.java:26)
        at UTPParser.typename(UTPParser.java:232)
        at UTPParser.vardecl(UTPParser.java:131)
        at UTPParser.declarationBlock(UTPParser.java:99)
        at UTPParser.utpspec(UTPParser.java:71)
        at UTP.main(UTP.java:20)

Here is the definition in the grammar.
*************************************************
typename returns [StringTemplate code=null]
    :   "int"  {code=template("type_int");}
    |   "nat"  {code=template("type_nat");}
    |   id:IDENT
        {
        code=template("type_user_def");
        code.setAttribute("name", id.getText());
        }
    ;
************************************************

Here is the definition the .stg

*************************************************
group Pvs;

utpspec(vars, commands) ::= <<
 <name> : THEORY
    BEGIN
	<vars>
	<commands>
>>

vardecl(name, typename) ::= "<name>, <name>' : VAR <type><\n>"
State: TYPE = "[<typename>,]"
IMPORTING UTPProg[State]
s : VAR State

globalVariable ::= vardecl

commandseq(typename,name,inits,cmds) ::= <<
 pre : pred[State] = 
    ( LAMBDA s : s(<name>) = 
    <inits>
    <cmds; separator="\n">
 END <name>
>>

type_int() ::= "int"

type_nat() ::= "nat"

type_user_def(name) ::= "<name>"

inits(typename, val) ::= "<typename> = <val>"
***********************************************

Thanks and best regards.

Joe.


More information about the antlr-interest mailing list