Refine search
public String getErrorMessage(RecognitionException e, String[] tokenNames) { if ( e instanceof SemanticException ) { return e.getMessage(); } else { return super.getErrorMessage(e, tokenNames); } }
public final JasminParser.sOwnerAndName_return sOwnerAndName() throws RecognitionException { JasminParser.sOwnerAndName_return retval = new JasminParser.sOwnerAndName_return(); retval.start = input.LT(1); switch ( input.LA(1) ) { case ARRAY_B: case ARRAY_C: case PARRAY_TYPE: int LA70_1 = input.LA(2); if ( (LA70_1==145) ) { alt70=1; state._fsp--; if((x!=null?input.toString(x.start,x.stop):null).contains("/")){ throw new RecognitionException(input);} retval.ownerInternalName =unEscape((a!=null?input.toString(a.start,a.stop):null)); retval.memberName =unEscape((x!=null?input.toString(x.start,x.stop):null)); state._fsp--; if((x!=null?input.toString(x.start,x.stop):null).contains("/")){ throw new RecognitionException(input);} retval.ownerInternalName =Type.getType(unEscape((b!=null?input.toString(b.start,b.stop):null))).getInternalName(); retval.memberName =unEscape((x!=null?input.toString(x.start,x.stop):null)); state._fsp--; String cstr=(c!=null?input.toString(c.start,c.stop):null); int idx=cstr.lastIndexOf('/'); if(idx<=0) { throw new RecognitionException(input); } retval.ownerInternalName =unEscape(cstr.substring(0,idx)); retval.memberName =unEscape(cstr.substring(idx+1));
private void assemble1(Path file, Path output) throws IOException { try (BufferedReader bufferedReader = Files.newBufferedReader(file, Charset.forName(encoding))) { ANTLRStringStream is = new ANTLRReaderStream(bufferedReader); is.name = file.toString(); JasminLexer lexer = new JasminLexer(is); CommonTokenStream ts = new CommonTokenStream(lexer); JasminParser parser = new JasminParser(ts); parser.rebuildLine = autogenLines; ClassWriter cw = new ClassWriter(noComputeMax?0:ClassWriter.COMPUTE_MAXS); ClassNode cn = parser.parse(); if (cn.version == 0) { cn.version = versions[classVersion]; } if (dump) { new JasminDumper(new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8), true)).dump(cn); } cn.accept(cw); Path clzFile = output.resolve(cn.name.replace('.', '/') + ".class"); createParentDirectories(clzFile); Files.write(clzFile, cw.toByteArray()); } catch (RecognitionException e) { System.err.println("Fail to assemble " + file); e.printStackTrace(); } } }
private boolean speculatePositionalConstraints() { state.backtracking++; int start = input.mark(); try { positionalConstraints( null ); // can never throw exception } catch ( RecognitionException re ) { System.err.println( "impossible: " + re ); re.printStackTrace(); } boolean success = !state.failed; input.rewind( start ); state.backtracking--; state.failed = false; return success; }
public RecognitionException(IntStream input) { this.input = input; this.index = input.index(); if ( input instanceof TokenStream ) { this.token = ((TokenStream)input).LT(1); this.line = token.getLine(); this.charPositionInLine = token.getCharPositionInLine(); } if ( input instanceof TreeNodeStream ) { extractInformationFromTreeNodeStream(input); } else if ( input instanceof CharStream ) { this.c = input.LA(1); this.line = ((CharStream)input).getLine(); this.charPositionInLine = ((CharStream)input).getCharPositionInLine(); } else { this.c = input.LA(1); } }
public final Token variable() throws RecognitionException { Token var = null; Token v=null; try { // org\\apache\\uima\\textmarker\\parser\\TextMarkerParser.g:802:2: ({...}?v= Identifier ) // org\\apache\\uima\\textmarker\\parser\\TextMarkerParser.g:803:2: {...}?v= Identifier { if ( !((isVariable(((blockDeclaration_scope)blockDeclaration_stack.peek()).env, input.LT(1).getText()))) ) { if (state.backtracking>0) {state.failed=true; return var;} throw new FailedPredicateException(input, "variable", "isVariable($blockDeclaration::env, input.LT(1).getText())"); } v=(Token)match(input,Identifier,FOLLOW_Identifier_in_variable3275); if (state.failed) return var; if ( state.backtracking==0 ) { var = v; } } } catch (RecognitionException exception1) { emitErrorMessage(exception1.toString()); } catch (Throwable exception2) { emitErrorMessage(exception2.toString()); } finally { } return var; } // $ANTLR end "variable"
public final BooleanFunctionParser.booleanExpression_return booleanExpression() throws RecognitionException { BooleanFunctionParser.booleanExpression_return retval = new BooleanFunctionParser.booleanExpression_return(); retval.start = input.LT(1); Object root_0 = null; BooleanFunctionParser.orTerm_return orTerm1 = null; try { // BooleanFunction.g:60:18: ( orTerm ) // BooleanFunction.g:60:22: orTerm { root_0 = (Object)adaptor.nil(); pushFollow(FOLLOW_orTerm_in_booleanExpression111); orTerm1=orTerm(); state._fsp--; adaptor.addChild(root_0, orTerm1.getTree()); if ( isTokenParenthesis(input.LT(1).getText()) ) throw new RecognitionException(); } retval.stop = input.LT(-1); retval.tree = (Object)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); } catch (RecognitionException e) { throw e; } finally { root_0 = null; orTerm1 = null; } return retval; } // $ANTLR end "booleanExpression"
problem.setLine(ex.line); problem.setColumn(ex.charPositionInLine); problem.setReason(ex.getMessage()); getParseProblems().add(problem); ex.printStackTrace(); Token next = parser.input.LT(1); problem.setLine(next.getLine()); problem.setColumn(next.getCharPositionInLine());
private void throwRecognitionException(Token t) throws RecognitionException { RecognitionException e = new RecognitionException(); e.token = t; e.line = t.getLine(); e.charPositionInLine = t.getCharPositionInLine(); e.input = input; throw e; }
if((type!=null?input.toString(type.start,type.stop):null) != null){ ls = new ListStatement((type!=null?input.toString(type.start,type.stop):null)); }else{ throw new RecognitionException();
@Test public void testAnalyzeBlock() { JavaExprAnalyzer analyzer = new JavaExprAnalyzer(); String codeBlock = "int x;\n"+ "Cheese cheese = new Cheese();\n"+ "for( Iterator it = list.iterator(); it.hasNext(); ) {\n" + " int shouldNotBeIncluded = 1;\n"+ "}\n" + "{\n" + " String anotherNonTopLevelVar = \"test\";\n" + "}\n" + "double thisIsAGoodVar = 0;\n" + "method();\n"; try { JavaAnalysisResult analysis = analyzer.analyzeBlock( codeBlock, new BoundIdentifiers( new HashMap<String, Class<?>>(), null ) ); Set<String> vars = analysis.getLocalVariables(); assertEquals( 3, vars.size() ); assertTrue( vars.contains( "x" )); assertTrue( vars.contains( "cheese" )); assertTrue( vars.contains( "thisIsAGoodVar" )); } catch ( RecognitionException e ) { e.printStackTrace(); fail( "Not supposed to raise exception: "+e.getMessage()); } }
StringBuilder errorMessage = new StringBuilder( 180 ); errorMessage.append( "error parsing edi on line " ).append( e.line ).append( " position " ).append( e.charPositionInLine ).append( ". " ).append( e.toString() );
private boolean speculateParameters( boolean requiresType ) { state.backtracking++; int start = input.mark(); try { parameters( null, requiresType ); // can never throw exception } catch ( RecognitionException re ) { System.err.println( "impossible: " + re ); re.printStackTrace(); } boolean success = !state.failed; input.rewind( start ); state.backtracking--; state.failed = false; return success; }
public RecognitionException(IntStream input) { this.input = input; this.index = input.index(); if ( input instanceof TokenStream ) { this.token = ((TokenStream)input).LT(1); this.line = token.getLine(); this.charPositionInLine = token.getCharPositionInLine(); } if ( input instanceof TreeNodeStream ) { extractInformationFromTreeNodeStream(input); } else if ( input instanceof CharStream ) { this.c = input.LA(1); this.line = ((CharStream)input).getLine(); this.charPositionInLine = ((CharStream)input).getCharPositionInLine(); } else { this.c = input.LA(1); } }
if ( !((isVariableOfType(((blockDeclaration_scope)blockDeclaration_stack.peek()).env, input.LT(1).getText(), "BOOLEANLIST") ||isVariableOfType(((blockDeclaration_scope)blockDeclaration_stack.peek()).env, input.LT(1).getText(), "INTLIST") ||isVariableOfType(((blockDeclaration_scope)blockDeclaration_stack.peek()).env, input.LT(1).getText(), "DOUBLELIST") ||isVariableOfType(((blockDeclaration_scope)blockDeclaration_stack.peek()).env, input.LT(1).getText(), "FLOATLIST") ||isVariableOfType(((blockDeclaration_scope)blockDeclaration_stack.peek()).env, input.LT(1).getText(), "STRINGLIST") emitErrorMessage(exception1.toString());
public final BooleanFunctionParser.booleanExpression_return booleanExpression() throws RecognitionException { BooleanFunctionParser.booleanExpression_return retval = new BooleanFunctionParser.booleanExpression_return(); retval.start = input.LT(1); Object root_0 = null; BooleanFunctionParser.orTerm_return orTerm1 = null; try { // BooleanFunction.g:60:18: ( orTerm ) // BooleanFunction.g:60:22: orTerm { root_0 = (Object)adaptor.nil(); pushFollow(FOLLOW_orTerm_in_booleanExpression111); orTerm1=orTerm(); state._fsp--; adaptor.addChild(root_0, orTerm1.getTree()); if ( isTokenParenthesis(input.LT(1).getText()) ) throw new RecognitionException(); } retval.stop = input.LT(-1); retval.tree = (Object)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); } catch (RecognitionException e) { throw e; } finally { } return retval; } // $ANTLR end "booleanExpression"
private void throwRecognitionException(Token t) throws RecognitionException { RecognitionException e = new RecognitionException(); e.token = t; e.line = t.getLine(); e.charPositionInLine = t.getCharPositionInLine(); e.input = input; throw e; }
public String getErrorMessage(RecognitionException e) { if (null == walker) { return e.toString(); } else { return getErrorMessage(walker, e); } }