(TokenStream tokens, Token templateToken, Parser parser, RecognitionException re)
| 176 | } |
| 177 | |
| 178 | protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken, Parser parser, RecognitionException re) { |
| 179 | if ( re.token.getType()==STLexer.EOF_TYPE ) { |
| 180 | String msg = "premature EOF"; |
| 181 | group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); |
| 182 | } |
| 183 | else if ( re instanceof NoViableAltException ) { |
| 184 | String msg = "'"+re.token.getText()+"' came as a complete surprise to me"; |
| 185 | group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); |
| 186 | } |
| 187 | else if ( tokens.index()==0 ) { // couldn't parse anything |
| 188 | String msg = "this doesn't look like a template: \""+tokens+"\""; |
| 189 | group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); |
| 190 | } |
| 191 | else if ( tokens.LA(1)==STLexer.LDELIM ) { // couldn't parse expr |
| 192 | String msg = "doesn't look like an expression"; |
| 193 | group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); |
| 194 | } |
| 195 | else { |
| 196 | String msg = parser.getErrorMessage(re, parser.getTokenNames()); |
| 197 | group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); |
| 198 | } |
| 199 | throw new STException(); // we have reported the error, so just blast out |
| 200 | } |
| 201 | } |
no test coverage detected