Top Description Fields Constructors Methods
org.jparsec

pack-priv Class Lexicon

extends Object
Class Inheritance
Known Direct Subclasses
org.jparsec.Terminals
Static Imports
org.jparsec.internal.util.Checks.checkArgument

A Lexicon is a group of lexical words that can be tokenized by a single tokenizer.
Author
Ben Yu

Field Summary

Modifier and TypeField and Description
pack-priv final Parser<?>
tokenizer

The scanner that recognizes any of the lexical word.

pack-priv final Function<String, Object>
words

Maps lexical word name to token value.

Constructor Summary

AccessConstructor and Description
pack-priv
Lexicon(Function<String, Object> words, Parser<?> tokenizer)

Method Summary

Modifier and TypeMethod and Description
pack-priv static <F, T> Function<F, T>
fallback(Function<F, T> function, Function<? super F, ? extends T> defaultFunction)

Returns a Function that delegates to function and falls back to defaultFunction for null return values.

public Parser<?>
phrase(String... tokenNames)

A Parser that recognizes a sequence of tokens identified by tokenNames, as an atomic step.

public Parser<Token>
token(String... tokenNames)

A Parser that recognizes a token identified by any of tokenNames.

public Parser<Token>
token(String tokenName)

A Parser that recognizes the token identified by tokenName.

public Parser<?>
tokenizer()

Returns the tokenizer that tokenizes all terminals (operators, keywords, identifiers etc.) managed in this instance.

pack-priv Lexicon
union(Lexicon that)

Returns a Lexicon instance that's a union of this and that.

pack-priv Object

Returns:

the token object.
word
(String
the token text.
name
)

Gets the token value identified by the token text.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tokenizerback to summary
pack-priv final Parser<?> tokenizer

The scanner that recognizes any of the lexical word.

wordsback to summary
pack-priv final Function<String, Object> words

Maps lexical word name to token value.

Constructor Detail

Lexiconback to summary
pack-priv Lexicon(Function<String, Object> words, Parser<?> tokenizer)

Method Detail

fallbackback to summary
pack-priv static <F, T> Function<F, T> fallback(Function<F, T> function, Function<? super F, ? extends T> defaultFunction)

Returns a Function that delegates to function and falls back to defaultFunction for null return values.

phraseback to summary
public Parser<?> phrase(String... tokenNames)

A Parser that recognizes a sequence of tokens identified by tokenNames, as an atomic step.

tokenback to summary
public Parser<Token> token(String... tokenNames)

A Parser that recognizes a token identified by any of tokenNames.

tokenback to summary
public Parser<Token> token(String tokenName)

A Parser that recognizes the token identified by tokenName.

tokenizerback to summary
public Parser<?> tokenizer()

Returns the tokenizer that tokenizes all terminals (operators, keywords, identifiers etc.) managed in this instance.

unionback to summary
pack-priv Lexicon union(Lexicon that)

Returns a Lexicon instance that's a union of this and that.

wordback to summary
pack-priv Object word(String name)

Gets the token value identified by the token text. This text is the operator or the keyword.

Parameters
name:String

the token text.

Returns:Object

the token object.

Annotations
@Private
Exceptions
IllegalArgumentException:
if the token object does not exist.