Class ThriftTokenizer
- java.lang.Object
-
- java.io.Reader
-
- net.morimekta.util.io.LineBufferedReader
-
- net.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
- net.morimekta.providence.reflect.parser.ThriftTokenizer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
,net.morimekta.util.lexer.Tokenizer<ThriftTokenType,ThriftToken>
public class ThriftTokenizer extends net.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
Specialization of the 'pretty' tokenizer to make it handle some special cases only applicable when parsing thrift files, but not allowed in pretty format or config files.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
kConst
static java.lang.String
kEnum
static java.lang.String
kException
static java.lang.String
kExtends
static java.lang.String
kImplements
static java.lang.String
kInclude
static java.lang.String
kInterface
static java.lang.String
kNamespace
static java.lang.String
kNull
static java.lang.String
kOf
static java.lang.String
kOneway
static java.lang.String
kOptional
static java.lang.String
kRequired
static java.lang.String
kService
static java.lang.String
kStruct
static java.lang.String
kThrows
static java.lang.String
kTypedef
static java.lang.String
kUnion
static java.lang.String
kVoid
-
Constructor Summary
Constructors Constructor Description ThriftTokenizer(java.io.InputStream in)
ThriftTokenizer(java.io.Reader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
allowIdentifier(int last)
protected ThriftToken
genericToken(char[] buffer, int offset, int len, ThriftTokenType type, int lineNo, int linePos)
protected ThriftToken
identifierToken(char[] buffer, int offset, int len, int lineNo, int linePos)
protected ThriftToken
nextSymbol()
protected ThriftToken
numberToken(char[] buffer, int offset, int len, int lineNo, int linePos)
ThriftToken
parseNextToken()
protected boolean
startString()
protected ThriftToken
stringToken(char[] buffer, int offset, int len, int lineNo, int linePos)
protected ThriftToken
symbolToken(char[] buffer, int offset, int len, int lineNo, int linePos)
-
Methods inherited from class net.morimekta.util.lexer.TokenizerBase
currentLine, currentLineNo, currentLinePos, eofFailure, failure, identifierSeparator, isWhitespace, readUntil, startIdentifier, startNumber, startSymbol, toString
-
Methods inherited from class net.morimekta.util.io.LineBufferedReader
close, getLine, getLineNo, getLinePos, getRemainingLines, getRestOfLine, maybeConsolidateBuffer, read, read, readNextChar
-
-
-
-
Field Detail
-
kNamespace
public static final java.lang.String kNamespace
- See Also:
- Constant Field Values
-
kInclude
public static final java.lang.String kInclude
- See Also:
- Constant Field Values
-
kTypedef
public static final java.lang.String kTypedef
- See Also:
- Constant Field Values
-
kEnum
public static final java.lang.String kEnum
- See Also:
- Constant Field Values
-
kStruct
public static final java.lang.String kStruct
- See Also:
- Constant Field Values
-
kUnion
public static final java.lang.String kUnion
- See Also:
- Constant Field Values
-
kException
public static final java.lang.String kException
- See Also:
- Constant Field Values
-
kInterface
public static final java.lang.String kInterface
- See Also:
- Constant Field Values
-
kConst
public static final java.lang.String kConst
- See Also:
- Constant Field Values
-
kService
public static final java.lang.String kService
- See Also:
- Constant Field Values
-
kExtends
public static final java.lang.String kExtends
- See Also:
- Constant Field Values
-
kVoid
public static final java.lang.String kVoid
- See Also:
- Constant Field Values
-
kOneway
public static final java.lang.String kOneway
- See Also:
- Constant Field Values
-
kThrows
public static final java.lang.String kThrows
- See Also:
- Constant Field Values
-
kRequired
public static final java.lang.String kRequired
- See Also:
- Constant Field Values
-
kOptional
public static final java.lang.String kOptional
- See Also:
- Constant Field Values
-
kImplements
public static final java.lang.String kImplements
- See Also:
- Constant Field Values
-
kOf
public static final java.lang.String kOf
- See Also:
- Constant Field Values
-
kNull
public static final java.lang.String kNull
- See Also:
- Constant Field Values
-
-
Method Detail
-
genericToken
protected ThriftToken genericToken(char[] buffer, int offset, int len, @Nonnull ThriftTokenType type, int lineNo, int linePos)
- Specified by:
genericToken
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
parseNextToken
@Nullable public ThriftToken parseNextToken() throws java.io.IOException
- Specified by:
parseNextToken
in interfacenet.morimekta.util.lexer.Tokenizer<ThriftTokenType,ThriftToken>
- Overrides:
parseNextToken
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
- Throws:
java.io.IOException
-
identifierToken
protected ThriftToken identifierToken(char[] buffer, int offset, int len, int lineNo, int linePos)
- Specified by:
identifierToken
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
stringToken
protected ThriftToken stringToken(char[] buffer, int offset, int len, int lineNo, int linePos)
- Specified by:
stringToken
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
numberToken
protected ThriftToken numberToken(char[] buffer, int offset, int len, int lineNo, int linePos)
- Specified by:
numberToken
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
symbolToken
protected ThriftToken symbolToken(char[] buffer, int offset, int len, int lineNo, int linePos)
- Specified by:
symbolToken
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
startString
protected boolean startString()
- Overrides:
startString
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
nextSymbol
@Nonnull protected ThriftToken nextSymbol() throws java.io.IOException
- Overrides:
nextSymbol
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
- Throws:
java.io.IOException
-
allowIdentifier
protected boolean allowIdentifier(int last)
- Overrides:
allowIdentifier
in classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
-