congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
CommonTokenStream.getTokenSource
Code IndexAdd Tabnine to your IDE (free)

How to use
getTokenSource
method
in
org.antlr.v4.runtime.CommonTokenStream

Best Java code snippets using org.antlr.v4.runtime.CommonTokenStream.getTokenSource (Showing top 8 results out of 315)

origin: antlr/codebuff

public CodeBuffTokenStream(CommonTokenStream stream) {
  super(stream.getTokenSource());
  this.fetchedEOF = false;
  for (Token t : stream.getTokens()) {
    tokens.add(new CommonToken(t));
  }
  reset();
}
origin: org.apache.tajo/tajo-core

 public void syntaxError(Recognizer<?, ?> recognizer,
             Object offendingSymbol,
             int line, int charPositionInLine,
             String msg,
             RecognitionException e) {
  CommonTokenStream tokens = (CommonTokenStream) recognizer.getInputStream();
  String input = tokens.getTokenSource().getInputStream().toString();
  Token token = (Token) offendingSymbol;
  String[] lines = StringUtils.splitPreserveAllTokens(input, '\n');
  String errorLine = lines[line - 1];

  String simpleMessage = "syntax error at or near \"" + token.getText() + "\"";
  throw new SQLParseError(token, line, charPositionInLine, simpleMessage, errorLine);
 }
}
origin: apache/tajo

 public void syntaxError(Recognizer<?, ?> recognizer,
             Object offendingSymbol,
             int line, int charPositionInLine,
             String msg,
             RecognitionException e) {
  CommonTokenStream tokens = (CommonTokenStream) recognizer.getInputStream();
  String input = tokens.getTokenSource().getInputStream().toString();
  Token token = (Token) offendingSymbol;
  String[] lines = StringUtils.splitPreserveAllTokens(input, '\n');
  String errorLine = lines[line - 1];

  String simpleMessage = "syntax error at or near \"" + token.getText() + "\"";
  throw new SQLParseError(token, line, charPositionInLine, simpleMessage, errorLine);
 }
}
origin: org.apache.sling/org.apache.sling.scripting.sightly.compiler

  @Override
  public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg,
              RecognitionException e) {
    String offendingInput;
    if (Parser.class.isAssignableFrom(recognizer.getClass())) {
      List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
      Collections.reverse(stack);
      offendingInput = ((CommonTokenStream) recognizer.getInputStream()).getTokenSource().getInputStream().toString();
    } else {
      offendingInput = recognizer.getInputStream().toString();
    }
    if (e != null) {
      throw new SightlyCompilerException(msg, offendingInput, line, charPositionInLine, e);
    }
    throw new SightlyCompilerException(msg, offendingInput, line, charPositionInLine);
  }
}
origin: antlr/intellij-plugin-v4

public static Token getTokenUnderCursor(CommonTokenStream tokens, int offset) {
  Comparator<Token> cmp = new Comparator<Token>() {
    @Override
    public int compare(Token a, Token b) {
      if ( a.getStopIndex() < b.getStartIndex() ) return -1;
      if ( a.getStartIndex() > b.getStopIndex() ) return 1;
      return 0;
    }
  };
  if ( offset<0 || offset >= tokens.getTokenSource().getInputStream().size() ) return null;
  CommonToken key = new CommonToken(Token.INVALID_TYPE, "");
  key.setStartIndex(offset);
  key.setStopIndex(offset);
  List<Token> tokenList = tokens.getTokens();
  Token tokenUnderCursor = null;
  int i = Collections.binarySearch(tokenList, key, cmp);
  if ( i>=0 ) tokenUnderCursor = tokenList.get(i);
  return tokenUnderCursor;
}
origin: com.github.cfparser/cfml.parsing

CFSCRIPTParser parser = new CFSCRIPTParser(tokens);
parser.removeErrorListeners();
if (tokens.getTokenSource() instanceof CFSCRIPTLexer) {
  ((CFSCRIPTLexer) tokens.getTokenSource()).addErrorListener(errorReporter);
  ((CFSCRIPTLexer) tokens.getTokenSource()).removeErrorListeners();
origin: antlr/intellij-plugin-v4

public static Token getSkippedTokenUnderCursor(CommonTokenStream tokens, int offset) {
  if ( offset<0 || offset >= tokens.getTokenSource().getInputStream().size() ) return null;
  Token prevToken = null;
  Token tokenUnderCursor = null;
    if ( (prevToken==null || offset > prevToken.getStopIndex()) && offset < begin ) {
      TokenSource tokenSource = tokens.getTokenSource();
      CharStream inputStream = null;
      if ( tokenSource!=null ) {
origin: antlr/intellij-plugin-v4

public static Token nextRealToken(CommonTokenStream tokens, int i) {
  int n = tokens.size();
  i++; // search after current i token
  if ( i>=n || i<0 ) return null;
  Token t = tokens.get(i);
  while ( t.getChannel()==Token.HIDDEN_CHANNEL ) {
    if ( t.getType()==Token.EOF ) {
      TokenSource tokenSource = tokens.getTokenSource();
      if ( tokenSource==null ) {
        return new CommonToken(Token.EOF, "EOF");
      }
      TokenFactory<?> tokenFactory = tokenSource.getTokenFactory();
      if ( tokenFactory==null ) {
        return new CommonToken(Token.EOF, "EOF");
      }
      return tokenFactory.create(Token.EOF, "EOF");
    }
    i++;
    if ( i>=n ) return null; // just in case no EOF
    t = tokens.get(i);
  }
  return t;
}
org.antlr.v4.runtimeCommonTokenStreamgetTokenSource

Popular methods of CommonTokenStream

  • <init>
    Constructs a new CommonTokenStream using the specified token source and filtering tokens to the spec
  • getTokens
  • fill
  • get
  • getHiddenTokensToLeft
  • size
  • LA
  • getHiddenTokensToRight
  • reset
  • seek
  • LB
  • getText
  • LB,
  • getText,
  • lazyInit,
  • nextTokenOnChannel,
  • previousTokenOnChannel,
  • sync,
  • LT,
  • consume,
  • index

Popular in Java

  • Parsing JSON documents to java classes using gson
  • startActivity (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • notifyDataSetChanged (ArrayAdapter)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JOptionPane (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now