Class Parser.Lexical
For example:
Parser<JsonRecord> jsonRecord = ...;
jsonRecord.zeroOrMoreDelimitedBy(",")
.between("[", "]")
.skipping(whitespace())
.parseToStream(jsonInput)
...;
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if this parser matches the entirety of theinput.Parsesinputwhile skipping the skippable patterns around lexical tokens.Parsesinputstarting fromfromIndexwhile skipping patterns around lexical tokens.parseToStream(Reader input) Parsesinputreader to a lazy stream while skipping the skippable patterns around lexical tokens.parseToStream(String input) Parsesinputto a lazy stream while skipping the skippable patterns around lexical tokens.parseToStream(String input, int fromIndex) Parsesinputstarting fromfromIndexto a lazy stream while skipping the skippable patterns around lexical tokens.Lazily and iteratively matchesinputreader, skipping the skippable patterns, until the input is exhausted or matching failed.Lazily and iteratively matchesinput, skipping the skippable patterns, until the input is exhausted or matching failed.Lazily and iteratively matchesinputstarting fromfromIndex, skipping the skippable patterns, until the input is exhausted or matching failed.
-
Method Details
-
parse
-
parse
-
matches
Returns true if this parser matches the entirety of theinput. It's similar to the regexMatcher.matches(String)method.If you don't need to match the entire input string, which is similar to the regex
Matcher.lookingAt(String)method, you can useparser.skipping(...).probe(input).findFirst().isPresent()to achieve the same effect.- Since:
- 9.9.1
-
parseToStream
-
parseToStream
-
parseToStream
Parsesinputreader to a lazy stream while skipping the skippable patterns around lexical tokens.UncheckedIOExceptionwill be thrown if the underlying reader throws.Characters are internally buffered, so you don't need to pass in
BufferedReader. -
probe
Lazily and iteratively matchesinput, skipping the skippable patterns, until the input is exhausted or matching failed.Note that unlike
parseToStream(), a matching failure terminates the stream without throwing exception.This allows quick probing without fully parsing it.
-
probe
Lazily and iteratively matchesinputstarting fromfromIndex, skipping the skippable patterns, until the input is exhausted or matching failed. Note that unlikeparseToStream(), a matching failure terminates the stream without throwing exception.This allows quick probing without fully parsing it.
-
probe
Lazily and iteratively matchesinputreader, skipping the skippable patterns, until the input is exhausted or matching failed.Note that unlike
parseToStream(), a matching failure terminates the stream without throwing exception.This allows quick probing without fully parsing it.
UncheckedIOExceptionwill be thrown if the underlying reader throws.Characters are internally buffered, so you don't need to pass in
BufferedReader.
-