//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_); } }
//throws RecognitionException, TokenStreamException public void groupInterface( StringTemplateGroupInterface groupI ) { IToken name = null; this.groupI = groupI; try { // for error handling match(LITERAL_interface); name = LT(1); match(ID); groupI.Name = name.getText(); match(SEMI); { // ( ... )+ int _cnt3=0; for (;;) { if ((LA(1)==ID||LA(1)==LITERAL_optional)) { template(groupI); } else { if (_cnt3 >= 1) { goto _loop3_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; } } _cnt3++; } _loop3_breakloop: ; } // ( ... )+ } catch (RecognitionException ex) { reportError(ex); recover(ex,tokenSet_0_); } }