public class Regex
extends java.lang.Object
easyIO.Scanner
easyIO.Scanner
Modifier and Type | Method and Description |
---|---|
static void |
advanceToPattern(BacktrackScanner sc,
Recognizer r)
Advance the scanner position to the point where the pattern recognized by
r is found, or all the way to the end of the input if it is not
found. |
static Recognizer |
alt(Recognizer a,
Recognizer b)
Recognizes either a or b (regular expression a|b)
|
static Recognizer |
anyChar(java.lang.String c)
Recognizer that matches any single character in the string
c |
static Recognizer |
concat(Recognizer a,
Recognizer b)
Recognizes a followed by b (regular expression ab)
|
static Recognizer |
constant(java.lang.String c)
Recognizes all of the characters in c, in sequence.
|
static boolean |
hasPattern(BacktrackScanner sc,
Recognizer r)
Whether the next characters on the input can be matched by r.
|
static Recognizer |
notChar(java.lang.String c)
Recognizer that matches any single character not in the string
c . |
static Recognizer |
oneOrMore(Recognizer a)
Recognizes 1 or more instances of a (a+)
|
static Recognizer |
opt(Recognizer a)
Recognizes 0 or 1 instance of a (regular expression a?)
|
static java.lang.String |
parsePattern(BacktrackScanner sc,
Recognizer r)
Match the input characters starting at the current position against the
pattern r and return the characters matched.
|
static java.lang.String |
parseToDelimiter(BacktrackScanner sc,
Recognizer delim)
Return all the characters from the current scanner position up to the
first occurrence of the delimiter pattern
delim , leaving the
scanner position either immediately after that delimiter pattern or at
the end of the string if the delimiter pattern was never found. |
static java.lang.String |
parseToPattern(BacktrackScanner sc,
Recognizer r)
Return all the text between the current scanner position and the
first occurrence of the pattern recognized by r.
|
static Recognizer |
repeat(Recognizer a)
Recognizes 0 or more instances of a (regular expression a*)
|
static void |
scanPattern(BacktrackScanner sc,
Recognizer r)
Match the input characters starting at the current position against the
pattern r and advance the scanner position beyond the matched characters.
|
static Recognizer |
whitespace()
Recognizer that matches a single whitespace character.
|
public static void scanPattern(BacktrackScanner sc, Recognizer r) throws UnexpectedInput
UnexpectedInput
if there is no way to match the input characters
against the pattern, and leave the scanner position unchanged.UnexpectedInput
public static java.lang.String parsePattern(BacktrackScanner sc, Recognizer r) throws UnexpectedInput
UnexpectedInput
public static java.lang.String parseToDelimiter(BacktrackScanner sc, Recognizer delim)
delim
, leaving the
scanner position either immediately after that delimiter pattern or at
the end of the string if the delimiter pattern was never found.public static boolean hasPattern(BacktrackScanner sc, Recognizer r)
public static void advanceToPattern(BacktrackScanner sc, Recognizer r)
r
is found, or all the way to the end of the input if it is not
found.public static java.lang.String parseToPattern(BacktrackScanner sc, Recognizer r)
public static Recognizer concat(Recognizer a, Recognizer b)
public static Recognizer alt(Recognizer a, Recognizer b)
public static Recognizer opt(Recognizer a)
public static Recognizer repeat(Recognizer a)
public static Recognizer oneOrMore(Recognizer a)
public static Recognizer constant(java.lang.String c)
public static Recognizer anyChar(java.lang.String c)
c
public static Recognizer notChar(java.lang.String c)
c
.public static Recognizer whitespace()