com.sonar.sslr.api
Class Token

java.lang.Object
  extended by com.sonar.sslr.api.Token

public final class Token
extends java.lang.Object

Tokens are string of character like an identifier, a literal, an integer, ... which are produced by the lexer to feed the parser. By definition, comments and preprocessing directives should not be seen by the parser that's why such Trivia, when they exist, are attached to the next token.


Nested Class Summary
static class Token.Builder
           
 
Method Summary
static Token.Builder builder()
           
static Token.Builder builder(Token token)
           
 int getColumn()
           
 java.lang.String getCopyBookOriginalFileName()
           
 int getCopyBookOriginalLine()
           
 int getLine()
           
 java.lang.String getOriginalValue()
           
 java.util.List<Trivia> getTrivia()
           
 TokenType getType()
           
 java.net.URI getURI()
           
 java.lang.String getValue()
           
 boolean hasTrivia()
           
 boolean isCopyBook()
           
 boolean isGeneratedCode()
           
 boolean isOnSameLineThan(Token other)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getType

public TokenType getType()

getValue

public java.lang.String getValue()

getOriginalValue

public java.lang.String getOriginalValue()
Returns:
the original value of the token. This method is useful when a language is case-insensitive as in that case all token values are capitalized.

getLine

public int getLine()
Returns:
the line of the token in the source code

getColumn

public int getColumn()
Returns:
the column of the token in the source code

getURI

public java.net.URI getURI()
Returns:
the URI this token belongs to

isCopyBook

public boolean isCopyBook()

isGeneratedCode

public boolean isGeneratedCode()

hasTrivia

public boolean hasTrivia()
Returns:
true if there is some trivia like some comments or preprocessing directive between this token and the previous one.

getTrivia

public java.util.List<Trivia> getTrivia()
Returns:
the list of trivia located between this token and the previous one

getCopyBookOriginalLine

public int getCopyBookOriginalLine()

getCopyBookOriginalFileName

public java.lang.String getCopyBookOriginalFileName()

isOnSameLineThan

public boolean isOnSameLineThan(Token other)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

builder

public static Token.Builder builder()

builder

public static Token.Builder builder(Token token)


Copyright © 2012 SonarSource. All Rights Reserved.