Examples of ToolANTLRLexer


Examples of org.antlr.v4.parse.ToolANTLRLexer

  }

  public GrammarRootAST parse(String fileName, CharStream in) {
    try {
      GrammarASTAdaptor adaptor = new GrammarASTAdaptor(in);
      ToolANTLRLexer lexer = new ToolANTLRLexer(in, this);
      CommonTokenStream tokens = new CommonTokenStream(lexer);
      lexer.tokens = tokens;
      ToolANTLRParser p = new ToolANTLRParser(tokens, this);
      p.setTreeAdaptor(adaptor);
      try {
        ParserRuleReturnScope r = p.grammarSpec();
        GrammarAST root = (GrammarAST)r.getTree();
        if ( root instanceof GrammarRootAST) {
          ((GrammarRootAST)root).hasErrors = lexer.getNumberOfSyntaxErrors()>0 || p.getNumberOfSyntaxErrors()>0;
          assert ((GrammarRootAST)root).tokenStream == tokens;
          if ( grammarOptions!=null ) {
            ((GrammarRootAST)root).cmdLineOptions = grammarOptions;
          }
          return ((GrammarRootAST)root);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.