//throws RecognitionException, TokenStreamException public void template( StringTemplateGroupInterface groupI ) { IToken opt = null; IToken name = null; HashList formalArgs = new HashList(); // leave blank if no args string templateName=null; try { // for error handling { switch ( LA(1) ) { case LITERAL_optional: { opt = LT(1); match(LITERAL_optional); break; } case ID: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } name = LT(1); match(ID); match(LPAREN); { switch ( LA(1) ) { case ID: { formalArgs=args(); break; } case RPAREN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } match(RPAREN); match(SEMI); templateName = name.getText(); groupI.DefineTemplate(templateName, formalArgs, opt!=null); } catch (RecognitionException ex) { reportError(ex); recover(ex,tokenSet_1_); } }