Package org.antlr.v4.runtime.misc

Examples of org.antlr.v4.runtime.misc.ParseCancellationException


    public void recover(Parser recognizer, RecognitionException e) {
    for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) {
      context.exception = e;
    }

        throw new ParseCancellationException(e);
    }
View Full Code Here


    InputMismatchException e = new InputMismatchException(recognizer);
    for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) {
      context.exception = e;
    }

        throw new ParseCancellationException(e);
    }
View Full Code Here

        return new BailErrorStrategy() { /* bail out at the first parse error */
            private void bail(Parser recognizer, Exception exc) {
                List<String> stack = recognizer.getRuleInvocationStack();
                Collections.reverse(stack);
                // TODO use recognizer.getRuleContext().toInfoString(recognizer); as the diagnostic ?
                throw new ParseCancellationException((exc.getMessage() != null ? exc.getMessage() + "; " : "") + (exc.getCause().getMessage() != null ? exc.getCause().getMessage() + "; " : "") + "in " + stack, exc.getCause());
            }

            @Override public void recover(Parser recognizer, RecognitionException e) {
                try {
                    super.recover(recognizer, e);    // TODO remove this call?
View Full Code Here

                }

                sb.append(additionalHint);
                underlineError(sb, recognizer, offendingToken);

                throw new ParseCancellationException(
                        sb.toString(),
                        exc.getCause()
                    );
            }
View Full Code Here

  public void exitFunction(final FunctionContext ctx) {
    final Token start = ctx.getStart();
    final String[] split = start.getText().split("\\(");
    final String functionName = split[0];
    if (!FunctionFactory.containsFunction(functionName)) {
      throw new ParseCancellationException(String.format("%s is not a valid function", functionName));
    }
  }
View Full Code Here

            final int lineNumber = mOffset + aLine;
            final Token token = (Token) aOffendingSymbol;

            if (JAVADOC_MISSED_HTML_CLOSE.equals(aMsg)) {
                log(lineNumber, JAVADOC_MISSED_HTML_CLOSE, token.getText());
                throw new ParseCancellationException();
            }
            else if (JAVADOC_WRONG_SINGLETON_TAG.equals(aMsg)) {
                log(lineNumber, JAVADOC_WRONG_SINGLETON_TAG, token.getText());
                throw new ParseCancellationException();
            }
            else {
                final RuleContext ruleContext = aEx.getCtx();
                if (ruleContext != null) {
                    final int ruleIndex = aEx.getCtx().getRuleIndex();
View Full Code Here

          }
        }
      }
      if(arg0.getParent() instanceof ExpressionContext) {
        // we are the leftmost child of the expression
        ParseTree chld = arg0.getParent().getChild(arg0.getParent().getChildCount()-1);
        if(!chld.equals(arg0)) return;
        addQuery(classUtils.expandExpression(arg0.getParent().getText(), registry));
      }
    }
  }
View Full Code Here

//    parser.setTokenFactory(factory);
    parser.addErrorListener(new DiagnosticErrorListener());
    parser.getInterpreter().setPredictionMode(
        PredictionMode.LL_EXACT_AMBIG_DETECTION);
    parser.setBuildParseTree(true);
    ParseTree tree = parser.mson();
    // show tree in text form
    // System.out.println(tree.toStringTree(parser));

    ParseTreeWalker walker = new ParseTreeWalker();
    SymbolTable symtab = new SymbolTable();
View Full Code Here

    JavaParser parser = new JavaParser(tokens);
    parser.removeErrorListeners();
   
    // start parsing at the compilationUnit rule
    ParserRuleContext t = parser.compilationUnit();
    ParseTreeWalker walker = new ParseTreeWalker();
    List<AutocompleteCandidate> q = new ArrayList<AutocompleteCandidate>();
         
    ImportDeclarationCompletion extractor = new ImportDeclarationCompletion(txt,cur,registry,cps,cu);
    NameBuilder extractor2 = new NameBuilder(registry,cu );
    NodeCompletion extractor3 = new NodeCompletion(txt,cur, registry, cu);
    walker.walk(extractor, t);
    if(extractor.getQuery()!=null)
      q.addAll(extractor.getQuery());
    walker.walk(extractor2, t);
    walker.walk(extractor3, t);
    if(extractor3.getQuery()!=null)
      q.addAll(extractor3.getQuery());
    List<String> ret = registry.searchCandidates(q);

    // this shows the GUI
View Full Code Here

    parser.setBuildParseTree(true);
    ParseTree tree = parser.mson();
    // show tree in text form
    // System.out.println(tree.toStringTree(parser));

    ParseTreeWalker walker = new ParseTreeWalker();
    SymbolTable symtab = new SymbolTable();
    DefPhase def = new DefPhase(symtab);
    walker.walk(def, tree);
    // create next phase and feed symbol table info from def to ref phase
    RefPhase ref = new RefPhase(symtab, def.scopes);
    walker.walk(ref, tree);
  }
View Full Code Here

TOP

Related Classes of org.antlr.v4.runtime.misc.ParseCancellationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.