public final class Scanners
extends java.lang.Object
All scanners return null. "_" is used as type parameter to indicate this.
Constructor and Description |
---|
Scanners() |
Modifier and Type | Method and Description |
---|---|
static Parser<_> |
among(char[] chars)
succeed and consume the current character if it equals to one of the given characters.
|
static Parser<_> |
among(char[] chars,
java.lang.String err)
succeed and consume the current character if it equals to one of the given characters.
|
static Parser<_> |
among(java.lang.String name,
char[] chars)
succeed and consume the current character if it equals to one of the given characters.
|
static Parser<_> |
among(java.lang.String name,
char[] chars,
java.lang.String err)
succeed and consume the current character if it equals to one of the given characters.
|
static Parser<_> |
anyChar()
matches any character in the input.
|
static Parser<_> |
anyChar(java.lang.String err)
matches any character in the input.
|
static Parser<_> |
anyChar(java.lang.String name,
java.lang.String err)
matches any character in the input.
|
static <R> Parser<R> |
delimited(Parser<R> s)
If a string is not followed by a alphanumeric character, it is well-delimited.
|
static <R> Parser<R> |
delimited(Parser<R> s,
java.lang.String err)
If a string is not followed by a alphanumeric character, it is well-delimited.
|
static <R> Parser<R> |
delimited(java.lang.String name,
Parser<R> s)
If a string is not followed by a alphanumeric character, it is well-delimited.
|
static <R> Parser<R> |
delimited(java.lang.String name,
Parser<R> s,
java.lang.String err)
If a string is not followed by a alphanumeric character, it is well-delimited.
|
static Parser<_> |
haskellBlockComment()
scanner for haskell style block comment.
|
static Parser<_> |
haskellDelimiter()
the haskell style delimiter of tokens.
|
static Parser<_> |
haskellDelimiter(java.lang.String name)
the haskell style delimiter of tokens.
|
static Parser<_> |
haskellLineComment()
scanner for haskell style line comment.
|
static Parser<_> |
isBlockComment(Parser<_> open,
Parser<_> close,
Parser<?> commented)
Scans a non-nestable block comment.
|
static Parser<_> |
isBlockComment(java.lang.String name,
Parser<_> open,
Parser<_> close,
Parser<?> commented)
Scans a non-nestable block comment.
|
static Parser<_> |
isBlockComment(java.lang.String start,
java.lang.String end)
scanner for non-nested block comment.
|
static Parser<_> |
isBlockComment(java.lang.String open,
java.lang.String close,
Pattern commented)
Scans a non-nestable block comment.
|
static Parser<_> |
isBlockComment(java.lang.String name,
java.lang.String start,
java.lang.String end)
scanner for non-nested block comment.
|
static Parser<_> |
isChar(char ch)
succeed and consume the current character if it is equal to ch.
|
static Parser<_> |
isChar(CharPredicate cp)
succeed and consume the current character if it satisfies the given CharPredicate.
|
static Parser<_> |
isChar(CharPredicate cp,
java.lang.String err)
succeed and consume the current character if it satisfies the given CharPredicate.
|
static Parser<_> |
isChar(char ch,
java.lang.String err)
succeed and consume the current character if it is equal to ch.
|
static Parser<_> |
isChar(java.lang.String name,
char ch)
succeed and consume the current character if it is equal to ch.
|
static Parser<_> |
isChar(java.lang.String name,
CharPredicate cp)
succeed and consume the current character if it satisfies the given CharPredicate.
|
static Parser<_> |
isChar(java.lang.String name,
CharPredicate cp,
java.lang.String err)
succeed and consume the current character if it satisfies the given CharPredicate.
|
static Parser<_> |
isChar(java.lang.String name,
char ch,
java.lang.String err)
succeed and consume the current character if it is equal to ch.
|
static Parser<_> |
isLineComment(java.lang.String start)
if the current input starts with the given string, succeed and consumes all the characters until the end of line '\n character.
|
static Parser<_> |
isLineComment(java.lang.String name,
java.lang.String start)
if the current input starts with the given string, succeed and consumes all the characters until the end of line '\n character.
|
static Parser<_> |
isNestableBlockComment(Parser<?> open,
Parser<?> close,
Parser<?> commented)
Scans a nestable block comment.
|
static Parser<_> |
isNestableBlockComment(java.lang.String name,
Parser<?> open,
Parser<?> close,
Parser<?> commented)
Scans a nestable block comment.
|
static Parser<_> |
isNestableBlockComment(java.lang.String open,
java.lang.String close)
Scans a nestable block comment.
|
static Parser<_> |
isNestableBlockComment(java.lang.String open,
java.lang.String close,
Parser<?> commented)
Scans a nestable block comment.
|
static Parser<_> |
isPattern(Pattern pp,
java.lang.String err)
Scans the input for an occurrence of a string pattern.
|
static Parser<_> |
isPattern(java.lang.String name,
Pattern pp,
java.lang.String err)
Scans the input for an occurrence of a string pattern.
|
static Parser<_> |
isQuotedChar()
scanner for a c/c++/java style character literal.
|
static Parser<_> |
isQuotedChar(java.lang.String name)
scanner for a c/c++/java style character literal.
|
static Parser<_> |
isQuotedString()
a scanner with a pattern for double quoted string literal.
|
static Parser<_> |
isQuotedString(java.lang.String name)
a scanner with a pattern for double quoted string literal.
|
static Parser<_> |
isSqlString()
a scanner with a pattern for sql server string literal.
|
static Parser<_> |
isSqlString(java.lang.String name)
a scanner with a pattern for sql server string literal.
|
static Parser<_> |
isString(java.lang.String str)
matches the input against the specified string.
|
static Parser<_> |
isString(java.lang.String str,
java.lang.String err)
matches the input against the specified string.
|
static Parser<_> |
isString(java.lang.String name,
java.lang.String str,
java.lang.String err)
matches the input against the specified string.
|
static Parser<_> |
isStringCI(java.lang.String str)
matches the input against the specified string case insensitively.
|
static Parser<_> |
isStringCI(java.lang.String str,
java.lang.String err)
matches the input against the specified string case insensitively.
|
static Parser<_> |
isStringCI(java.lang.String name,
java.lang.String str,
java.lang.String err)
matches the input against the specified string case insensitively.
|
static Parser<_> |
isWhitespaces()
Scans greedily for 1 or more whitespace characters.
|
static Parser<_> |
isWhitespaces(java.lang.String name)
Scans greedily for 1 or more whitespace characters.
|
static Parser<_> |
isWhitespaces(java.lang.String name,
java.lang.String err)
Scans greedily for 1 or more whitespace characters.
|
static Parser<_> |
javaBlockComment()
scanner for c++/java style block comment.
|
static Parser<_> |
javaDelimiter()
the c++/java style delimiter of tokens.
|
static Parser<_> |
javaDelimiter(java.lang.String name)
the c++/java style delimiter of tokens.
|
static Parser<_> |
javaLineComment()
scanner for c++/java style line comment.
|
static Parser<Tok[]> |
lexeme(Parser<?> delim,
Parser<Tok> s)
Deprecated.
|
static Parser<Tok[]> |
lexeme(java.lang.String name,
Parser<?> delim,
Parser<Tok> s)
Deprecated.
|
static Parser<Tok> |
lexer(Parser<?> s,
Tokenizer tn)
Deprecated.
|
static Parser<Tok> |
lexer(Parser<?> s,
Tokenizer tn,
java.lang.String err)
Deprecated.
|
static Parser<Tok> |
lexer(java.lang.String name,
Parser<?> s,
Tokenizer tn)
Deprecated.
|
static Parser<Tok> |
lexer(java.lang.String name,
Parser<?> s,
Tokenizer tn,
java.lang.String err)
Deprecated.
|
static Parser<_> |
many(CharPredicate cp)
Scans greedily for 0 or more characters
that satisfies the given CharPredicate.
|
static Parser<_> |
many(Pattern pp)
Scans greedily for 0 or more occurrences of the given pattern.
|
static Parser<_> |
many(java.lang.String name,
CharPredicate cp)
Scans greedily for 0 or more characters
that satisfies the given CharPredicate.
|
static Parser<_> |
many(java.lang.String name,
Pattern pp)
Scans greedily for 0 or more occurrences of the given pattern.
|
static Parser<_> |
many1(CharPredicate cp)
Scans greedily for 1 or more characters
that satisfies the given CharPredicate.
|
static Parser<_> |
many1(Pattern pp)
Scans greedily for 1 or more occurrences of the given pattern.
|
static Parser<_> |
many1(java.lang.String name,
CharPredicate cp)
Scans greedily for 1 or more characters
that satisfies the given CharPredicate.
|
static Parser<_> |
many1(java.lang.String name,
Pattern pp)
Scans greedily for 1 or more occurrences of the given pattern.
|
static Parser<_> |
notAmong(char[] chars)
succeed and consume the current character if it is not equal to any of the given characters.
|
static Parser<_> |
notAmong(char[] chars,
java.lang.String err)
succeed and consume the current character if it is not equal to any of the given characters.
|
static Parser<_> |
notAmong(java.lang.String name,
char[] chars)
succeed and consume the current character if it is not equal to any of the given characters.
|
static Parser<_> |
notAmong(java.lang.String name,
char[] chars,
java.lang.String err)
succeed and consume the current character if it is not equal to any of the given characters.
|
static Parser<_> |
notChar(char ch)
succeed and consume the current character if it is not equal to ch.
|
static Parser<_> |
notChar(char ch,
java.lang.String err)
succeed and consume the current character if it is equal to ch.
|
static Parser<_> |
notChar(java.lang.String name,
char ch)
succeed and consume the current character if it is not equal to ch.
|
static Parser<_> |
notChar(java.lang.String name,
char ch,
java.lang.String err)
succeed and consume the current character if it is not equal to ch.
|
static Parser<_> |
quoted(char c1,
char c2)
scans a quoted string that is opened by c1 and closed by c2.
|
static Parser<_> |
quoted(Parser<_> open,
Parser<_> close,
Parser<?> s)
scans a quoted string that is opened by c1 and closed by c2.
|
static Parser<_> |
quoted(java.lang.String name,
char c1,
char c2)
scans a quoted string that is opened by c1 and closed by c2.
|
static Parser<_> |
quoted(java.lang.String name,
Parser<_> open,
Parser<_> close,
Parser<?> s)
scans a quoted string that is opened by pattern represented by Scanner open and closed by pattern represented by Scanner close.
|
static Parser<_> |
scanChars(Parser<?> p,
Parser<_> scanner,
java.lang.String module)
After character level parser p succeeds,
subsequently feed the recognized characters to the Parser scanner
for a nested scanning.
|
static Parser<_> |
scanChars(java.lang.String name,
Parser<?> p,
Parser<_> scanner,
java.lang.String module)
After character level parser p succeeds,
subsequently feed the recognized characters to the Parser scanner
for a nested scanning.
|
static Parser<_> |
sqlDelimiter()
the T-SQL style delimiter of tokens.
|
static Parser<_> |
sqlDelimiter(java.lang.String name)
the T-SQL style delimiter of tokens.
|
static Parser<_> |
sqlLineComment()
scanner for T-SQL style line comment.
|
static Parser<_> |
stdDelimiter(java.lang.String lcomment,
java.lang.String openc,
java.lang.String closec)
Any delimiter with whitespace, non-nested block comment and line comment.
|
static Parser<_> |
stdDelimiter(java.lang.String name,
java.lang.String lcomment,
java.lang.String openc,
java.lang.String closec)
Any delimiter with whitespace, non-nested block comment and line comment.
|
public static Parser<_> many(CharPredicate cp)
cp
- the predicate object.public static Parser<_> many1(CharPredicate cp)
cp
- the predicate object.public static Parser<_> many(Pattern pp)
pp
- the pattern object.public static Parser<_> many1(Pattern pp)
pp
- the pattern object.public static Parser<_> many(java.lang.String name, CharPredicate cp)
name
- the name of the Parser object.cp
- the predicate object.public static Parser<_> many1(java.lang.String name, CharPredicate cp)
name
- the name of the Parser object.cp
- the predicate object.public static Parser<_> many(java.lang.String name, Pattern pp)
name
- the name of the Parser object.pp
- the pattern object.public static Parser<_> many1(java.lang.String name, Pattern pp)
name
- the name of the Parser object.pp
- the pattern object.public static Parser<_> isString(java.lang.String str)
str
- the string to matchpublic static Parser<_> isString(java.lang.String str, java.lang.String err)
str
- the string to matcherr
- the error message if fails.public static Parser<_> isString(java.lang.String name, java.lang.String str, java.lang.String err)
name
- the scanner name.str
- the string to matcherr
- the error message if fails.public static Parser<_> isWhitespaces()
public static Parser<_> isWhitespaces(java.lang.String name)
name
- the Parser object name.public static Parser<_> isWhitespaces(java.lang.String name, java.lang.String err)
name
- the Parser object name.err
- the expected message when fails.public static Parser<_> isPattern(Pattern pp, java.lang.String err)
pp
- the pattern object.err
- the expected message when fails.public static Parser<_> isPattern(java.lang.String name, Pattern pp, java.lang.String err)
name
- the Parser object name.pp
- the pattern object.err
- the expected message when fails.public static Parser<_> isStringCI(java.lang.String str, java.lang.String err)
str
- the string to matcherr
- the error message if fails.public static Parser<_> isStringCI(java.lang.String name, java.lang.String str, java.lang.String err)
name
- the scanner name.str
- the string to matcherr
- the error message if fails.public static Parser<_> isStringCI(java.lang.String str)
str
- the string to matchpublic static Parser<_> anyChar()
public static Parser<_> anyChar(java.lang.String err)
err
- the error message if fails.public static Parser<_> anyChar(java.lang.String name, java.lang.String err)
name
- the scanner name.err
- the error message if fails.public static Parser<_> isChar(CharPredicate cp)
cp
- the predicate.public static Parser<_> isChar(java.lang.String name, CharPredicate cp)
name
- the scanner name.cp
- the predicate.public static Parser<_> isChar(CharPredicate cp, java.lang.String err)
cp
- the predicate.err
- the error message.public static Parser<_> isChar(java.lang.String name, CharPredicate cp, java.lang.String err)
name
- the scanner name.cp
- the predicate.err
- the error message.public static Parser<_> isChar(char ch, java.lang.String err)
ch
- the expected character.err
- the error message.public static Parser<_> isChar(java.lang.String name, char ch, java.lang.String err)
name
- the scanner name.ch
- the expected character.err
- the error message.public static Parser<_> isChar(char ch)
ch
- the expected character.public static Parser<_> isChar(java.lang.String name, char ch)
name
- the scanner name.ch
- the expected character.public static Parser<_> notChar(char ch, java.lang.String err)
ch
- the expected character.err
- the error message.public static Parser<_> notChar(java.lang.String name, char ch, java.lang.String err)
name
- the scanner name.ch
- the expected character.err
- the error message.public static Parser<_> notChar(char ch)
ch
- the expected character.public static Parser<_> notChar(java.lang.String name, char ch)
name
- the scanner name.ch
- the expected character.public static Parser<_> among(java.lang.String name, char[] chars, java.lang.String err)
name
- the scanner name.chars
- the characters.err
- the error message when the character is not among the given values.public static Parser<_> among(java.lang.String name, char[] chars)
name
- the scanner name.chars
- the characters.public static Parser<_> among(char[] chars, java.lang.String err)
chars
- the characters.err
- the error message when the character is not among the given values.public static Parser<_> among(char[] chars)
chars
- the characters.public static Parser<_> notAmong(java.lang.String name, char[] chars, java.lang.String err)
name
- the scanner name.chars
- the characters.err
- the error message when the character is among the given values.public static Parser<_> notAmong(java.lang.String name, char[] chars)
name
- the scanner name.chars
- the characters.public static Parser<_> notAmong(char[] chars, java.lang.String err)
chars
- the characters.err
- the error message when the character is not among the given values.public static Parser<_> notAmong(char[] chars)
chars
- the characters.public static Parser<_> isLineComment(java.lang.String start)
start
- the start string.public static Parser<_> isLineComment(java.lang.String name, java.lang.String start)
name
- the scanner name.start
- the start string.public static Parser<_> javaLineComment()
public static Parser<_> sqlLineComment()
public static Parser<_> javaBlockComment()
public static Parser<_> haskellBlockComment()
public static Parser<_> haskellLineComment()
public static Parser<_> isBlockComment(java.lang.String start, java.lang.String end)
start
- the start string of a block comment.end
- the end string of a block comment.public static Parser<_> isBlockComment(java.lang.String name, java.lang.String start, java.lang.String end)
name
- the scanner name.start
- the start string of a block comment.end
- the end string of a block comment.public static Parser<_> isBlockComment(java.lang.String open, java.lang.String close, Pattern commented)
open
- the opening string.close
- the closing string.commented
- the commented pattern.public static Parser<_> isBlockComment(Parser<_> open, Parser<_> close, Parser<?> commented)
open
- the opening pattern.close
- the closing pattern.commented
- the commented pattern.public static Parser<_> isBlockComment(java.lang.String name, Parser<_> open, Parser<_> close, Parser<?> commented)
name
- the name of the block comment scanner.open
- the opening pattern.close
- the closing pattern.commented
- the commented pattern.public static Parser<_> isNestableBlockComment(java.lang.String open, java.lang.String close)
open
- the opening pattern.close
- the closing pattern.public static Parser<_> isNestableBlockComment(java.lang.String open, java.lang.String close, Parser<?> commented)
open
- the opening string.close
- the closing string.commented
- the commented pattern except for nested comments.public static Parser<_> isNestableBlockComment(Parser<?> open, Parser<?> close, Parser<?> commented)
open
- the opening pattern.close
- the closing pattern.commented
- the commented pattern except for nested comments.public static Parser<_> isNestableBlockComment(java.lang.String name, Parser<?> open, Parser<?> close, Parser<?> commented)
name
- the name of the block comment scanner.open
- the opening pattern.close
- the closing pattern.commented
- the commented pattern except for nested comments.public static Parser<_> isSqlString()
public static Parser<_> isSqlString(java.lang.String name)
name
- the name of the scanner.public static Parser<_> isQuotedString(java.lang.String name)
name
- the name of the scanner.public static Parser<_> isQuotedString()
public static Parser<_> isQuotedChar(java.lang.String name)
name
- the name of the scanner.public static Parser<_> isQuotedChar()
public static Parser<_> quoted(char c1, char c2)
c1
- the opening character.c2
- the closing character.public static Parser<_> quoted(java.lang.String name, char c1, char c2)
name
- the scanner name.c1
- the opening character.c2
- the closing character.public static Parser<_> quoted(Parser<_> open, Parser<_> close, Parser<?> s)
open
- the opening character.close
- the closing character.public static Parser<_> quoted(java.lang.String name, Parser<_> open, Parser<_> close, Parser<?> s)
name
- the scanner name.open
- the scanner for the opening pattern.close
- the scanner for the closing pattern.public static Parser<_> javaDelimiter()
public static Parser<_> javaDelimiter(java.lang.String name)
name
- the scanner name.public static Parser<_> haskellDelimiter()
public static Parser<_> haskellDelimiter(java.lang.String name)
name
- the scanner name.public static Parser<_> sqlDelimiter()
public static Parser<_> sqlDelimiter(java.lang.String name)
name
- the scanner name.public static Parser<_> stdDelimiter(java.lang.String name, java.lang.String lcomment, java.lang.String openc, java.lang.String closec)
name
- the scanner name.lcomment
- line comment starting string.openc
- block comment opening string.closec
- block comment closing string.public static Parser<_> stdDelimiter(java.lang.String lcomment, java.lang.String openc, java.lang.String closec)
lcomment
- line comment starting string.openc
- block comment opening string.closec
- block comment closing string.public static <R> Parser<R> delimited(Parser<R> s, java.lang.String err)
s
- the scanner for the to-be-delimited pattern.err
- the error message if it is not delimited.public static <R> Parser<R> delimited(java.lang.String name, Parser<R> s, java.lang.String err)
name
- the new scanner name.s
- the scanner for the to-be-delimited pattern.err
- the error message if it is not delimited.public static <R> Parser<R> delimited(Parser<R> s)
s
- the scanner for the to-be-delimited pattern.public static <R> Parser<R> delimited(java.lang.String name, Parser<R> s)
name
- the new scanner name.s
- the scanner for the to-be-delimited pattern.public static Parser<_> scanChars(Parser<?> p, Parser<_> scanner, java.lang.String module)
p
- the first parser object to identify the characters.scanner
- the second parser object to scan the characters again.module
- the module name.public static Parser<_> scanChars(java.lang.String name, Parser<?> p, Parser<_> scanner, java.lang.String module)
name
- the name of the new Parser object.p
- the first parser object to identify the characters.scanner
- the second parser object to scan the characters again.module
- the module name.@Deprecated public static Parser<Tok[]> lexeme(Parser<?> delim, Parser<Tok> s)
delim
- the delimiter Parser object.s
- the Parser object.@Deprecated public static Parser<Tok[]> lexeme(java.lang.String name, Parser<?> delim, Parser<Tok> s)
name
- the name of the new Parser object.delim
- the delimiter Parser object.s
- the Parser object.@Deprecated public static Parser<Tok> lexer(Parser<?> s, Tokenizer tn)
s
- the scanner to transform.tn
- the Tokenizer object.@Deprecated public static Parser<Tok> lexer(Parser<?> s, Tokenizer tn, java.lang.String err)
s
- the scanner to transform.tn
- the Tokenizer object.err
- the error message when the tokenizer returns null.@Deprecated public static Parser<Tok> lexer(java.lang.String name, Parser<?> s, Tokenizer tn)
name
- the name of the new Scanner.tn
- the Tokenizer object.s
- the scanner to transform.@Deprecated public static Parser<Tok> lexer(java.lang.String name, Parser<?> s, Tokenizer tn, java.lang.String err)
name
- the name of the new Scanner.s
- the scanner to transform.tn
- the Tokenizer object.err
- the error message when the tokenizer returns null.