List<String>: Terminals terms = Terminals
.operators("?", "<", ">", ",")
.words(Scanners.IDENTIFIER)
.keywords("super", "extends")
.build();
Parser<String> typeName = Terminals.identifier();
Parser<?> wildcardWithUpperBound = terms.phrase("?", "extends");
...
parser.from(terms.tokenizer(), Scanners.WHITESPACES.optional()).parse("List<String>");
| Modifier and Type | Class and Description |
|---|---|
| public class | Terminals.
Builds |
| public static class | Terminals.
Entry point for parser and tokenizers of character literal. |
| public static class | Terminals.
Entry point for parser and tokenizers of decimal number literal represented as |
| public static class | Terminals.
Entry point for parser and tokenizers of regular identifier. |
| public static class | Terminals.
Entry point for any arbitrary integer literal represented as a |
| public static class | Terminals.
Entry point for parser and tokenizers of integral number literal represented as |
| public static class | Terminals.
Entry point for parser and tokenizers of scientific notation literal. |
| public static class | Terminals.
Entry point for parser and tokenizers of string literal. |
| Modifier and Type | Field and Description |
|---|---|
| public static final Parser |
| Modifier and Type | Method and Description |
|---|---|
| public static Terminals | Returns: the Terminals instance.the operator names. ops, String[] the keyword names. keywords)
Deprecated
Use
operators(ops)
.words(Scanners.IDENTIFIER)
.caseInsensitiveKeywords(keywords)
.build() instead.
Returns a |
| public static Terminals | Returns: the Terminals instance.the scanner that returns a word in the language. wordScanner, String[] the operator names. ops, String[] the keyword names. keywords)
Deprecated
Use
operators(ops)
.words(wordScanner)
.caseInsensitiveKeywords(keywords)
.build() instead.
Returns a |
| public static Terminals | Returns: the Terminals instance.the scanner that returns a word in the language. wordScanner, String[] the operator names. ops, String[] the keyword names. keywords, Function<String, ?> maps the text to a token value for non-keywords recognized by
wordMap)wordScanner.
Deprecated
Use
operators(ops)
.words(wordScanner)
.tokenizeWordsWith(wordMap)
.caseInsensitiveKeywords(keywords)
.build() instead.
Returns a |
| public static Terminals | Returns: the Terminals instance.the operator names. ops, String[] the keyword names. keywords)
Deprecated
Use
operators(ops)
.words(Scanners.IDENTIFIER)
.keywords(keywords)
.build() instead.
Returns a |
| public static Terminals | Returns: the Terminals instance.the scanner that returns a word in the language. wordScanner, String[] the operator names. ops, String[] the keyword names. keywords)
Deprecated
Use
operators(ops)
.words(wordScanner)
.keywords(keywords)
.build() instead.
Returns a |
| public static Terminals | Returns: the Terminals instance.the scanner that returns a word in the language. wordScanner, String[] the operator names. ops, String[] the keyword names. keywords, Function<String, ?> maps the text to a token value for non-keywords recognized by
wordMap)wordScanner.
Deprecated
Use
operators(ops)
.words(wordScanner)
.tokenizeWordsWith(wordMap)
.keywords(keywords)
.build() instead.
Returns a |
| pack-priv static void | |
| public static Parser | fragment(final Object... tags)
Returns a |
| pack-priv static TokenMap | fromFragment(final Object... tags)
Returns a |
| public static Parser | |
| public static Terminals | |
| public static Terminals | Returns: the Terminals instance.the operator names. ops)Returns a |
| public Terminals. |
| RESERVED | back to summary |
|---|---|
| public static final Parser<String> RESERVED
| |
| Terminals | back to summary |
|---|---|
| private Terminals(Lexicon lexicon) | |
| caseInsensitive | back to summary |
|---|---|
| public static Terminals caseInsensitive(String[] ops, String[] keywords)
Deprecated Use Returns a In detail, keywords and operators are lexed as A word is defined as an alphanumeric string that starts with
| |
| caseInsensitive | back to summary |
|---|---|
| public static Terminals caseInsensitive(Parser<String> wordScanner, String[] ops, String[] keywords)
Deprecated Use Returns a In detail, keywords and operators are lexed as | |
| caseInsensitive | back to summary |
|---|---|
| public static Terminals caseInsensitive(Parser<String> wordScanner, String[] ops, String[] keywords, Function<String, ?> wordMap)
Deprecated Use Returns a In detail, keywords and operators are lexed as
| |
| caseSensitive | back to summary |
|---|---|
| public static Terminals caseSensitive(String[] ops, String[] keywords)
Deprecated Use Returns a In detail, keywords and operators are lexed as A word is defined as an alphanumeric string that starts with
| |
| caseSensitive | back to summary |
|---|---|
| public static Terminals caseSensitive(Parser<String> wordScanner, String[] ops, String[] keywords)
Deprecated Use Returns a In detail, keywords and operators are lexed as | |
| caseSensitive | back to summary |
|---|---|
| public static Terminals caseSensitive(Parser<String> wordScanner, String[] ops, String[] keywords, Function<String, ?> wordMap)
Deprecated Use Returns a In detail, keywords and operators are lexed as
| |
| checkDup | back to summary |
|---|---|
pack-priv static void checkDup(Iterable<String> a, Iterable<String> b)
| |
| fragment | back to summary |
|---|---|
| public static Parser Returns a | |
| fromFragment | back to summary |
|---|---|
| pack-priv static TokenMap Returns a | |
| identifier | back to summary |
|---|---|
| public static Parser Returns a
| |
| operators | back to summary |
|---|---|
| public static Terminals operators(String... ops) Returns a If words and keywords need to be parsed, they can be configured via | |
| operators | back to summary |
|---|---|
| public static Terminals operators(Collection<String> ops) Returns a If words and keywords need to be parsed, they can be configured via
| |
| words | back to summary |
|---|---|
| public Terminals. Starts to build a new By default identifiers are recognized through | |
Terminals instance by defining the words and keywords recognized.
The following example implements a calculator with logical operators: Terminals terms = Terminals
.operators("<", ">", "=", ">=", "<=")
.words(Scanners.IDENTIFIER)
.caseInsensitiveKeywords("and", "or")
.build();
Parser<String> var = Terminals.identifier();
Parser<Integer> integer = Terminals.IntegerLiteral.PARSER.map(...);
Parser<?> and = terms.token("and");
Parser<?> lessThan = terms.token("<");
...
Parser<?> parser = grammar.from(
terms.tokenizer().or(IntegerLiteral.TOKENIZER), Scanners.WHITSPACES.optional());
| Modifier and Type | Field and Description |
|---|---|
| private Collection | |
| private StringCase | |
| private final Parser | |
| private Function |
| Modifier and Type | Method and Description |
|---|---|
| public Terminals | |
| public Terminals. | |
| public Terminals. | |
| public Terminals. | |
| public Terminals. | |
| public Terminals. | tokenizeWordsWith(Function<String, ?> wordMap)
Configures alternative tokenization strategy for words (except keywords). |
| keywords | back to summary |
|---|---|
| private Collection<String> keywords | |
| stringCase | back to summary |
|---|---|
| private StringCase stringCase | |
| wordScanner | back to summary |
|---|---|
| private final Parser<String> wordScanner | |
| wordTokenMap | back to summary |
|---|---|
| private Function<String, ?> wordTokenMap | |
| Builder | back to summary |
|---|---|
| pack-priv Builder(Parser<String> wordScanner) | |
| build | back to summary |
|---|---|
| public Terminals build() Builds a new | |
| caseInsensitiveKeywords | back to summary |
|---|---|
| public Terminals. Defines case insensitive keywords. Keywords are special words with their own grammar
rules. To get the parser for a keyword, call Note that if you call | |
| caseInsensitiveKeywords | back to summary |
|---|---|
| public Terminals. Defines case insensitive keywords. Keywords are special words with their own grammar
rules. To get the parser for a keyword, call Note that if you call | |
| keywords | back to summary |
|---|---|
| public Terminals. Defines keywords. Keywords are special words with their own grammar rules.
To get the parser for a keyword, call Note that if you call | |
| keywords | back to summary |
|---|---|
| public Terminals. Defines keywords. Keywords are special words with their own grammar rules.
To get the parser for a keyword, call Note that if you call | |
| tokenizeWordsWith | back to summary |
|---|---|
| public Terminals. Configures alternative tokenization strategy for words (except keywords). | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Parser | |
| public static final Parser | SINGLE_QUOTE_TOKENIZER
A tokenizer that parses single quoted character literal (escaped by |
| Access | Constructor and Description |
|---|---|
| private |
| PARSER | back to summary |
|---|---|
| public static final Parser<Character> PARSER | |
| SINGLE_QUOTE_TOKENIZER | back to summary |
|---|---|
| public static final Parser<Character> SINGLE_QUOTE_TOKENIZER A tokenizer that parses single quoted character literal (escaped by | |
| CharLiteral | back to summary |
|---|---|
| private CharLiteral() | |
String.
| Modifier and Type | Field and Description |
|---|---|
| public static final Parser | PARSER
|
| public static final Parser | TOKENIZER
A tokenizer that parses a decimal number (valid patterns are: |
| Access | Constructor and Description |
|---|---|
| private |
| PARSER | back to summary |
|---|---|
| public static final Parser<String> PARSER
| |
| TOKENIZER | back to summary |
|---|---|
| public static final Parser<Tokens. A tokenizer that parses a decimal number (valid patterns are: | |
| DecimalLiteral | back to summary |
|---|---|
| private DecimalLiteral() | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Parser | |
| public static final Parser | TOKENIZER
A tokenizer that parses any identifier and returns a |
| Access | Constructor and Description |
|---|---|
| private |
| PARSER | back to summary |
|---|---|
| public static final Parser<String> PARSER
| |
| TOKENIZER | back to summary |
|---|---|
| public static final Parser<Tokens. A tokenizer that parses any identifier and returns a An identifier starts with an alphabetic character or underscore, and is followed by 0 or more alphanumeric characters or underscore. | |
| Identifier | back to summary |
|---|---|
| private Identifier() | |
String.
| Modifier and Type | Field and Description |
|---|---|
| public static final Parser | PARSER
|
| public static final Parser | TOKENIZER
A tokenizer that parses a integer number (valid patterns are: |
| Access | Constructor and Description |
|---|---|
| private |
| PARSER | back to summary |
|---|---|
| public static final Parser<String> PARSER
| |
| TOKENIZER | back to summary |
|---|---|
| public static final Parser<Tokens. A tokenizer that parses a integer number (valid patterns are: | |
| IntegerLiteral | back to summary |
|---|---|
| private IntegerLiteral() | |
Long.
| Modifier and Type | Field and Description |
|---|---|
| public static final Parser | DEC_TOKENIZER
A tokenizer that parses a decimal integer number (valid patterns are: |
| public static final Parser | HEX_TOKENIZER
A tokenizer that parses a hex integer number (valid patterns are:
|
| public static final Parser | OCT_TOKENIZER
A tokenizer that parses a octal integer number (valid patterns are:
|
| public static final Parser | |
| public static final Parser | TOKENIZER
A tokenizer that parses decimal, hex, and octal numbers and converts the string to a
|
| Access | Constructor and Description |
|---|---|
| private |
| DEC_TOKENIZER | back to summary |
|---|---|
| public static final Parser<Long> DEC_TOKENIZER A tokenizer that parses a decimal integer number (valid patterns are: | |
| HEX_TOKENIZER | back to summary |
|---|---|
| public static final Parser<Long> HEX_TOKENIZER A tokenizer that parses a hex integer number (valid patterns are:
A hex number has to start with either 0x or 0X. | |
| OCT_TOKENIZER | back to summary |
|---|---|
| public static final Parser<Long> OCT_TOKENIZER A tokenizer that parses a octal integer number (valid patterns are:
An octal number has to start with 0. | |
| PARSER | back to summary |
|---|---|
| public static final Parser<Long> PARSER | |
| TOKENIZER | back to summary |
|---|---|
| public static final Parser<Long> TOKENIZER A tokenizer that parses decimal, hex, and octal numbers and converts the string to a
| |
| LongLiteral | back to summary |
|---|---|
| private LongLiteral() | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Parser | PARSER
|
| public static final Parser | TOKENIZER
A tokenizer that parses a scientific notation and converts the string to a
|
| Access | Constructor and Description |
|---|---|
| private |
| PARSER | back to summary |
|---|---|
| public static final Parser<Tokens.
| |
| TOKENIZER | back to summary |
|---|---|
| public static final Parser<Tokens. A tokenizer that parses a scientific notation and converts the string to a
| |
| ScientificNumberLiteral | back to summary |
|---|---|
| private ScientificNumberLiteral() | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Parser | DOUBLE_QUOTE_TOKENIZER
A tokenizer that parses double quoted string literal (escaped by |
| public static final Parser | |
| public static final Parser | SINGLE_QUOTE_TOKENIZER
A tokenizer that parses single quoted string literal (single quote is escaped with another single quote), and transforms the quoted content by applying escape characters. |
| Access | Constructor and Description |
|---|---|
| private |
| DOUBLE_QUOTE_TOKENIZER | back to summary |
|---|---|
| public static final Parser<String> DOUBLE_QUOTE_TOKENIZER A tokenizer that parses double quoted string literal (escaped by | |
| PARSER | back to summary |
|---|---|
| public static final Parser<String> PARSER | |
| SINGLE_QUOTE_TOKENIZER | back to summary |
|---|---|
| public static final Parser<String> SINGLE_QUOTE_TOKENIZER A tokenizer that parses single quoted string literal (single quote is escaped with another single quote), and transforms the quoted content by applying escape characters. | |
| StringLiteral | back to summary |
|---|---|
| private StringLiteral() | |