Package org.jparsec
Class Lexicon
- java.lang.Object
-
- org.jparsec.Lexicon
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <F,T>
java.util.function.Function<F,T>fallback(java.util.function.Function<F,T> function, java.util.function.Function<? super F,? extends T> defaultFunction)Returns aFunctionthat delegates tofunctionand falls back todefaultFunctionfor null return values.Parser<?>phrase(java.lang.String... tokenNames)AParserthat recognizes a sequence of tokens identified bytokenNames, as an atomic step.Parser<Token>token(java.lang.String tokenName)AParserthat recognizes the token identified bytokenName.Parser<Token>token(java.lang.String... tokenNames)AParserthat recognizes a token identified by any oftokenNames.Parser<?>tokenizer()Returns the tokenizer that tokenizes all terminals (operators, keywords, identifiers etc.) managed in this instance.(package private) Lexiconunion(Lexicon that)(package private) java.lang.Objectword(java.lang.String name)Gets the token value identified by the token text.
-
-
-
Field Detail
-
words
final java.util.function.Function<java.lang.String,java.lang.Object> words
Maps lexical word name to token value.
-
tokenizer
final Parser<?> tokenizer
The scanner that recognizes any of the lexical word.
-
-
Constructor Detail
-
Lexicon
Lexicon(java.util.function.Function<java.lang.String,java.lang.Object> words, Parser<?> tokenizer)
-
-
Method Detail
-
tokenizer
public Parser<?> tokenizer()
Returns the tokenizer that tokenizes all terminals (operators, keywords, identifiers etc.) managed in this instance.
-
phrase
public Parser<?> phrase(java.lang.String... tokenNames)
AParserthat recognizes a sequence of tokens identified bytokenNames, as an atomic step.
-
token
public Parser<Token> token(java.lang.String... tokenNames)
AParserthat recognizes a token identified by any oftokenNames.
-
token
public Parser<Token> token(java.lang.String tokenName)
AParserthat recognizes the token identified bytokenName.
-
word
java.lang.Object word(java.lang.String name)
Gets the token value identified by the token text. This text is the operator or the keyword.- Parameters:
name- the token text.- Returns:
- the token object.
- Throws:
java.lang.IllegalArgumentException- if the token object does not exist.
-
fallback
static <F,T> java.util.function.Function<F,T> fallback(java.util.function.Function<F,T> function, java.util.function.Function<? super F,? extends T> defaultFunction)Returns aFunctionthat delegates tofunctionand falls back todefaultFunctionfor null return values.
-
-