Package cc.redberry.rings.io
Class Tokenizer
java.lang.Object
cc.redberry.rings.io.Tokenizer
- All Implemented Interfaces:
Serializable
public final class Tokenizer extends Object implements Serializable
Simple math expression tokenizer
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Tokenizer.CharacterStream
Stream of chars.static class
Tokenizer.Token
Simple tokenstatic class
Tokenizer.TokenType
token type -
Field Summary
Fields Modifier and Type Field Description static Tokenizer.Token
BRACKET_CLOSE
static Tokenizer.Token
BRACKET_OPEN
static Tokenizer.Token
DIVIDE
static Tokenizer.Token
END
static Tokenizer.Token
EXPONENT
static Tokenizer.Token
MINUS
static Tokenizer.Token
MULTIPLY
static Tokenizer.Token
PLUS
static Tokenizer.Token
SPACE
-
Constructor Summary
Constructors Constructor Description Tokenizer(Tokenizer.CharacterStream stream)
Create tokenizer of a given char stream -
Method Summary
Modifier and Type Method Description static Tokenizer.CharacterStream
concat(Tokenizer.CharacterStream a, Tokenizer.CharacterStream b)
Concat char streamsstatic Tokenizer.CharacterStream
mkCharacterStream(String string, Character terminateChar)
Create character stream from stringstatic Tokenizer
mkTokenizer(String string)
Create string tokenizerstatic Tokenizer
mkTokenizer(String string, Character terminateChar)
Create string tokenizerTokenizer.Token
nextToken()
Get the next token from stream
-
Field Details
-
END
-
PLUS
-
MINUS
-
MULTIPLY
-
DIVIDE
-
EXPONENT
-
BRACKET_OPEN
-
BRACKET_CLOSE
-
SPACE
-
-
Constructor Details
-
Tokenizer
Create tokenizer of a given char stream
-
-
Method Details
-
nextToken
Get the next token from stream -
concat
public static Tokenizer.CharacterStream concat(Tokenizer.CharacterStream a, Tokenizer.CharacterStream b)Concat char streams -
mkCharacterStream
Create character stream from string- Parameters:
terminateChar
- if a non-null value specified, stream will terminate on the last char preceding theterminateChar
-
mkTokenizer
Create string tokenizer- Parameters:
terminateChar
- if a non-null value specified, stream will terminate on the last char preceding theterminateChar
-
mkTokenizer
Create string tokenizer
-