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.StringkConststatic java.lang.StringkEnumstatic java.lang.StringkExceptionstatic java.lang.StringkExtendsstatic java.lang.StringkImplementsstatic java.lang.StringkIncludestatic java.lang.StringkInterfacestatic java.lang.StringkNamespacestatic java.lang.StringkNullstatic java.lang.StringkOfstatic java.lang.StringkOnewaystatic java.lang.StringkOptionalstatic java.lang.StringkRequiredstatic java.lang.StringkServicestatic java.lang.StringkStructstatic java.lang.StringkThrowsstatic java.lang.StringkTypedefstatic java.lang.StringkUnionstatic java.lang.StringkVoid
-
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 booleanallowIdentifier(int last)protected ThriftTokengenericToken(char[] buffer, int offset, int len, ThriftTokenType type, int lineNo, int linePos)protected ThriftTokenidentifierToken(char[] buffer, int offset, int len, int lineNo, int linePos)protected ThriftTokennextSymbol()protected ThriftTokennumberToken(char[] buffer, int offset, int len, int lineNo, int linePos)ThriftTokenparseNextToken()protected booleanstartString()protected ThriftTokenstringToken(char[] buffer, int offset, int len, int lineNo, int linePos)protected ThriftTokensymbolToken(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:
genericTokenin classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
parseNextToken
@Nullable public ThriftToken parseNextToken() throws java.io.IOException
- Specified by:
parseNextTokenin interfacenet.morimekta.util.lexer.Tokenizer<ThriftTokenType,ThriftToken>- Overrides:
parseNextTokenin 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:
identifierTokenin classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
stringToken
protected ThriftToken stringToken(char[] buffer, int offset, int len, int lineNo, int linePos)
- Specified by:
stringTokenin classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
numberToken
protected ThriftToken numberToken(char[] buffer, int offset, int len, int lineNo, int linePos)
- Specified by:
numberTokenin classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
symbolToken
protected ThriftToken symbolToken(char[] buffer, int offset, int len, int lineNo, int linePos)
- Specified by:
symbolTokenin classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
startString
protected boolean startString()
- Overrides:
startStringin classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
nextSymbol
@Nonnull protected ThriftToken nextSymbol() throws java.io.IOException
- Overrides:
nextSymbolin classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>- Throws:
java.io.IOException
-
allowIdentifier
protected boolean allowIdentifier(int last)
- Overrides:
allowIdentifierin classnet.morimekta.util.lexer.TokenizerBase<ThriftTokenType,ThriftToken>
-
-