Interface Production<T>
- All Known Implementing Classes:
Parser,Parser.OrEmpty,Parser.Rule
Parser or an optional Parser.OrEmpty.
Useful as a parameter to Parser.sequence() methods, so as to avoid overload explosion.
- Since:
- 10.0
-
Method Summary
Modifier and TypeMethodDescriptionThe current production must be enclosed betweenprefixthat may be empty andsuffixthat may not be empty.Returns a production rule that matchesthispattern enclosed betweenprefixandsuffix,* both allowed to be empty.The current production must be enclosed between non-emptyprefixandsuffix.The current production must be enclosed between non-emptyprefixandsuffixthat may be empty.The current production must be enclosed between non-emptyprefixandsuffix.followedBy(Parser<?> suffix) The current production must be followed by non-emptysuffix.<S> Production<T> followedBy(Parser<S>.OrEmpty suffix) The current production may optionally be followed bysuffix.followedBy(String suffix) The current production must be followed by non-emptysuffix.immediatelyBetween(String prefix, String suffix) The current production must be immediately enclosed between non-emptyprefixandsuffix(no skippable characters as specified byparseSkipping()in between).booleanReturns true if this production rule matches the entirety ofinputstring.<S> Production<T> optionallyFollowedBy(Parser<S> suffix, BiFunction<? super T, ? super S, ? extends T> op) If this production rule matches, optionally matchessuffixwith theopBiFunction to transform the current production's result.optionallyFollowedBy(String suffix) Returns an equivalent production except it allowssuffixif present.optionallyFollowedBy(String suffix, Function<? super T, ? extends T> op) If this production rule matches, optionally applies theopfunction if this production is followed bysuffix.Parses the entire input string and returns the result.parseSkipping(Parser<?> skip, String input) Parses the entire input string, ignoring patterns matched byskip, and returns the result.parseSkipping(CharPredicate charsToSkip, String input) Parses the entire input string, ignoringcharsToSkip, and returns the result.<S> Parser<S> After matching the current production, proceed to matchsuffix.<S> Production<S> After matching the current production rule, proceed to matchsuffix.
-
Method Details
-
parse
Parses the entire input string and returns the result. Upon successful return, theinputis fully consumed.- Throws:
Parser.ParseException- if the input cannot be parsed.
-
parseSkipping
Parses the entire input string, ignoring patterns matched byskip, and returns the result.- Throws:
Parser.ParseException- if the input cannot be parsed.
-
parseSkipping
Parses the entire input string, ignoringcharsToSkip, and returns the result.- Throws:
Parser.ParseException- if the input cannot be parsed.
-
matches
Returns true if this production rule matches the entirety ofinputstring. -
between
-
between
-
between
-
between
-
between
Returns a production rule that matchesthispattern enclosed betweenprefixandsuffix,* both allowed to be empty.Note that the
ParserandParser.OrEmptyimplementations are re-declared to return the more specificParser<T>orParser<T>.OrEmptysubtypes respectively. -
immediatelyBetween
The current production must be immediately enclosed between non-emptyprefixandsuffix(no skippable characters as specified byparseSkipping()in between). Useful for matching a literal string, such aszeroOrMore(isNot('"')).immediatelyBetween("\"", "\""). -
then
-
then
After matching the current production rule, proceed to matchsuffix.Note that the
ParserandParser.OrEmptyimplementations are re-declared to return the more specificParser<S>orParser<S>.OrEmptysubtypes respectively. -
followedBy
-
followedBy
-
followedBy
The current production may optionally be followed bysuffix.Note that the
ParserandParser.OrEmptyimplementations are re-declared to return the more specificParser<T>orParser<T>.OrEmptysubtypes respectively. -
optionallyFollowedBy
Returns an equivalent production except it allowssuffixif present.Note that the
ParserandParser.OrEmptyimplementations are re-declared to return the more specificParser<T>orParser<T>.OrEmptysubtypes respectively. -
optionallyFollowedBy
If this production rule matches, optionally applies theopfunction if this production is followed bysuffix.Note that the
ParserandParser.OrEmptyimplementations are re-declared to return the more specificParser<T>orParser<T>.OrEmptysubtypes respectively. -
optionallyFollowedBy
<S> Production<T> optionallyFollowedBy(Parser<S> suffix, BiFunction<? super T, ? super S, ? extends T> op) If this production rule matches, optionally matchessuffixwith theopBiFunction to transform the current production's result.Note that the
ParserandParser.OrEmptyimplementations are re-declared to return the more specificParser<T>orParser<T>.OrEmptysubtypes respectively.
-