Package com.sonar.sslr.api
Class Token
- java.lang.Object
-
- com.sonar.sslr.api.Token
-
public class Token extends 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
Nested Classes Modifier and Type Class Description static class
Token.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAllTrivia(List<Trivia> currentTrivia)
FIXME no such method in SSLR 1.9static Token.Builder
builder()
static Token.Builder
builder(Token token)
int
getColumn()
List<Offsets>
getContinuationOffsets()
Deprecated.since 4.2, usegetContinuations()
.List<TokenContinuation>
getContinuations()
String
getCopyBookOriginalFileName()
int
getCopyBookOriginalLine()
int
getEndOffset()
File
getFile()
FIXME no such method in SSLR 1.9int
getLine()
String
getOriginalValue()
int
getStartLineOffset()
int
getStartOffset()
List<Trivia>
getTrivia()
TokenType
getType()
URI
getURI()
String
getValue()
boolean
hasTrivia()
boolean
isCopyBook()
boolean
isGeneratedCode()
boolean
isOnSameLineThan(Token other)
boolean
isReplacement()
void
setCopyBook(boolean copyBook)
FIXME no such method in SSLR 1.9void
setCopyBookOriginalFileName(String copyBookOriginalFileName)
FIXME no such method in SSLR 1.9void
setCopyBookOriginalLine(int copyBookOriginalLine)
FIXME no such method in SSLR 1.9void
setGeneratedCode(boolean b)
FIXME no such method in SSLR 1.9String
toString()
-
-
-
Method Detail
-
getType
public TokenType getType()
-
getValue
public String getValue()
-
getOriginalValue
public 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
-
getStartOffset
public int getStartOffset()
-
getEndOffset
public int getEndOffset()
-
getStartLineOffset
public int getStartLineOffset()
-
getURI
public URI getURI()
- Returns:
- the URI this token belongs to
-
isCopyBook
public boolean isCopyBook()
-
isGeneratedCode
public boolean isGeneratedCode()
-
isReplacement
public boolean isReplacement()
-
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 List<Trivia> getTrivia()
- Returns:
- the list of trivia located between this token and the previous one
-
getCopyBookOriginalLine
public int getCopyBookOriginalLine()
-
getCopyBookOriginalFileName
public String getCopyBookOriginalFileName()
-
isOnSameLineThan
public boolean isOnSameLineThan(Token other)
-
getContinuationOffsets
@Deprecated public List<Offsets> getContinuationOffsets()
Deprecated.since 4.2, usegetContinuations()
.
-
getContinuations
public List<TokenContinuation> getContinuations()
-
builder
public static Token.Builder builder()
-
builder
public static Token.Builder builder(Token token)
-
setGeneratedCode
public void setGeneratedCode(boolean b)
FIXME no such method in SSLR 1.9
-
getFile
public File getFile()
FIXME no such method in SSLR 1.9
-
setCopyBook
public void setCopyBook(boolean copyBook)
FIXME no such method in SSLR 1.9
-
setCopyBookOriginalFileName
public void setCopyBookOriginalFileName(String copyBookOriginalFileName)
FIXME no such method in SSLR 1.9
-
setCopyBookOriginalLine
public void setCopyBookOriginalLine(int copyBookOriginalLine)
FIXME no such method in SSLR 1.9
-
-