[stringtemplate-interest] Output error?

Micheal J open.zone at virgin.net
Fri May 5 08:03:48 PDT 2006


Ensure you're using the right lexer. You want the AngleBracketTemplateLexer.
Try setting it explicitly.

-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Glenn
Williams
Sent: 05 May 2006 15:10
To: stringtemplate-interest at antlr.org
Subject: [stringtemplate-interest] Output error?


The following code from the String Template Documentation page is returning
"<type> <name>" when it should be returning "int foo".  If I load this from
a single file the output is "vardef(type,name) ::= <type> <name>;". What am
I doing wrong?
 
/// template
group simple;
 
vardef(type,name) ::= "<type> <name>;"
 
method(type,name,args) ::= <<
<type> <name>(<args; separator=",">) {
  <statements; separator="\n">
}
>>

 
/// code  
 
StringTemplateGroup groupf;
  try
  {
   groupf = new StringTemplateGroup( new FileReader(
     "simple.st" ) );
   StringTemplate t = groupf.getInstanceOf( "vardef" );
   t.setAttribute( "type", "int" );
   t.setAttribute( "name", "foo" );
   System.out.println( t );
  }
  catch ( FileNotFoundException e )
  {
   e.printStackTrace();
  }


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20060505/d6be5576/attachment-0001.html


More information about the stringtemplate-interest mailing list