Interface TokenMatcher
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface that replaces using Pattern for sometimes easier, more understandable and more
flexible pattern matching during lexing
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic TokenMatcherforChar(char character) Creates a token matcher for a single characterstatic TokenMatcherforIString(String string) Creates a token matcher for a single characterstatic TokenMatcherforLineComment(String startsWith) static TokenMatcherforPattern(String regex) static TokenMatcherforPattern(Pattern pattern) Creates a token matcher for aPatternstatic TokenMatcherCreates a token matcher for a quoted string.static TokenMatcherforQuotedString(char quoteChar) Creates a token matcher for a quoted string.static TokenMatcherforQuotedString(Set<Character> quoteWith) Creates a token matcher for a string quoted with any of the characters in the given set.static TokenMatcherCreates a token matcher for a single character
-
Field Details
-
DEFAULT_QUOTES
-
LINE_ENDINGS
-
-
Method Details
-
forChar
Creates a token matcher for a single character
-
forString
Creates a token matcher for a single character
-
forIString
Creates a token matcher for a single character
-
forPattern
-
forPattern
Creates a token matcher for a
Pattern -
forQuotedString
Creates a token matcher for a quoted string. Strings can be quoted with either single or double quotes and escaping is done by adding a backslash in front of the used quote (aka the mode) character
-
forQuotedString
Creates a token matcher for a quoted string. Strings can be quoted with either single or double quotes and escaping is done by adding a backslash in front of the used quote (aka the mode) character
-
forQuotedString
Creates a token matcher for a string quoted with any of the characters in the given set. The quote characters operate in a 'mode' - that is if one of these characters is seen in the source, that triggers that 'mode' and the quoting is terminated by seeing that character again.
Escaping is always done with a backslash
-
match
- Parameters:
source- string to match a token fromposition- place in string where to start matching from- Returns:
- a
Tokenthat is built frompositioninsource, ornullif it doesn't match
-
forLineComment
-
getKeyword
-