Examples of CommonToken


Examples of org.antlr.runtime.CommonToken

    this.atnState = node.atnState;
    this.textOverride = node.textOverride;
  }
    public GrammarAST(int type) { super(new CommonToken(type, ANTLRParser.tokenNames[type])); }
    public GrammarAST(int type, Token t) {
    this(new CommonToken(t));
    token.setType(type);
  }
View Full Code Here

Examples of org.antlr.runtime.CommonToken

    public GrammarAST(int type, Token t) {
    this(new CommonToken(t));
    token.setType(type);
  }
    public GrammarAST(int type, Token t, String text) {
    this(new CommonToken(t));
    token.setType(type);
    token.setText(text);
    }
View Full Code Here

Examples of org.antlr.runtime.CommonToken

    //System.out.println("actions="+chunks);
  }

  public Action(OutputModelFactory factory, StructDecl ctx, String action) {
    super(factory,null);
    ActionAST ast = new ActionAST(new CommonToken(ANTLRParser.ACTION, action));
    RuleFunction rf = factory.getCurrentRuleFunction();
    if ( rf!=null ) { // we can translate
      ast.resolver = rf.rule;
      chunks = ActionTranslator.translateActionChunk(factory, rf, action, ast);
    }
View Full Code Here

Examples of org.antlr.runtime.CommonToken

         */
        charPositionInLine += action.getToken().getCharPositionInLine() + 1;
      }

      int offset = ((CommonToken)action.getToken()).getStartIndex();
      attr.token = new CommonToken(action.getToken().getInputStream(), ANTLRParser.ID, BaseRecognizer.DEFAULT_TOKEN_CHANNEL, offset + declOffset + start + 1, offset + declOffset + stop);
      attr.token.setLine(line);
      attr.token.setCharPositionInLine(charPositionInLine);
      assert attr.name.equals(attr.token.getText()) : "Attribute text should match the pseudo-token text at this point.";
    }

View Full Code Here

Examples of org.antlr.runtime.CommonToken

    /** Make sure even imaginary nodes know the input stream */
    public Object create(int tokenType, String text) {
    GrammarAST t;
    if ( tokenType==ANTLRParser.RULE ) {
      // needed by TreeWizard to make RULE tree
          t = new RuleAST(new CommonToken(tokenType, text));
    }
    else if ( tokenType==ANTLRParser.STRING_LITERAL ) {
      // implicit lexer construction done with wizard; needs this node type
      // whereas grammar ANTLRParser.g can use token option to spec node type
      t = new TerminalAST(new CommonToken(tokenType, text));
    }
    else {
      t = (GrammarAST)super.create(tokenType, text);
    }
        t.token.setInputStream(input);
View Full Code Here

Examples of org.antlr.runtime.CommonToken

  {
    String template = templateStream.substring(0, templateStream.size() - 1);
    String templateName = Misc.getFileNameNoSuffix(unqualifiedFileName);
    String fullyQualifiedTemplateName = prefix + templateName;
    CompiledST impl = new Compiler(this).compile(fullyQualifiedTemplateName, template);
    CommonToken nameT = new CommonToken(STLexer.SEMI); // Seems like a hack, best I could come up with.
    nameT.setInputStream(templateStream);
    rawDefineTemplate(fullyQualifiedTemplateName, impl, nameT);
    impl.defineImplicitlyDefinedTemplates(this);
    return impl;
  }
View Full Code Here

Examples of org.antlr.runtime.CommonToken

            TreePath path = treeSelectionEvent.getNewLeadSelectionPath();
            if ( path==null ) return;
            CommonTree node = (CommonTree)treeSelectionEvent.getNewLeadSelectionPath().getLastPathComponent();
            //System.out.println("select AST: "+node);
            CommonToken a = (CommonToken)currentScope.st.impl.tokens.get(node.getTokenStartIndex());
            CommonToken b = (CommonToken)currentScope.st.impl.tokens.get(node.getTokenStopIndex());
            highlight(viewFrame.template, a.getStartIndex(), b.getStopIndex());
          }
          finally {
            updateDepth.decrementAndGet();
          }
        }
View Full Code Here

Examples of org.antlr.runtime3_3_0.CommonToken

    }

    // Wildcard?
    if ( ttype == TreePatternLexer.DOT ) {
      ttype = tokenizer.nextToken();
      Token wildcardPayload = new CommonToken(0, ".");
      TreeWizard.TreePattern node =
        new TreeWizard.WildcardTreePattern(wildcardPayload);
      if ( label!=null ) {
        node.label = label;
      }
View Full Code Here

Examples of org.antlr.v4.runtime.CommonToken

  @Test public void testOffChannel() throws Exception {
        TokenSource lexer = // simulate input " x =34  ;\n"
            new TokenSource() {
                int i = 0;
                WritableToken[] tokens = {
                    new CommonToken(1," ") {{channel = Lexer.HIDDEN;}},
                    new CommonToken(1,"x"),
                    new CommonToken(1," ") {{channel = Lexer.HIDDEN;}},
                    new CommonToken(1,"="),
                    new CommonToken(1,"34"),
                    new CommonToken(1," ") {{channel = Lexer.HIDDEN;}},
                    new CommonToken(1," ") {{channel = Lexer.HIDDEN;}},
                    new CommonToken(1,";"),
                    new CommonToken(1,"\n") {{channel = Lexer.HIDDEN;}},
                    new CommonToken(Token.EOF,"")
                };
                @Override
                public Token nextToken() {
                    return tokens[i++];
                }
View Full Code Here

Examples of org.antlr.v4.runtime.CommonToken

    TokenSource lexer = // simulate input " x =34  ; \n"
                        // token indexes   01234 56789
      new TokenSource() {
        int i = 0;
        WritableToken[] tokens = {
        new CommonToken(1," ") {{channel = Lexer.HIDDEN;}}, // 0
        new CommonToken(1,"x"),                // 1
        new CommonToken(1," ") {{channel = Lexer.HIDDEN;}}// 2
        new CommonToken(1,"="),                // 3
        new CommonToken(1,"34"),              // 4
        new CommonToken(1," ") {{channel = Lexer.HIDDEN;}}// 5
        new CommonToken(1," ") {{channel = Lexer.HIDDEN;}}, // 6
        new CommonToken(1,";"),                // 7
        new CommonToken(1," ")  {{channel = Lexer.HIDDEN;}},// 8
        new CommonToken(1,"\n") {{channel = Lexer.HIDDEN;}},// 9
        new CommonToken(Token.EOF,"")            // 10
        };
        @Override
        public Token nextToken() {
          return tokens[i++];
        }
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.