Class Parser.Lexical

java.lang.Object
com.google.common.labs.parse.Parser.Lexical
Enclosing class:
Parser<T>

public final class Parser.Lexical extends Object
Fluent API for parsing while skipping patterns around lexical tokens.

For example:


 Parser<JsonRecord> jsonRecord = ...;
 jsonRecord.zeroOrMoreDelimitedBy(",")
     .between("[", "]")
     .skipping(whitespace())
     .parseToStream(jsonInput)
     ...;
 
  • Method Summary

    Modifier and Type
    Method
    Description
    parse(String input)
    Parses input while skipping the skippable patterns around lexical tokens.
    parse(String input, int fromIndex)
    Parses input starting from fromIndex while skipping patterns around lexical tokens.
    Parses input reader to a lazy stream while skipping the skippable patterns around lexical tokens.
    Parses input to a lazy stream while skipping the skippable patterns around lexical tokens.
    parseToStream(String input, int fromIndex)
    Parses input starting from fromIndex to a lazy stream while skipping the skippable patterns around lexical tokens.
    probe(Reader input)
    Lazily and iteratively matches input reader, skipping the skippable patterns, until the input is exhausted or matching failed.
    probe(String input)
    Lazily and iteratively matches input, skipping the skippable patterns, until the input is exhausted or matching failed.
    probe(String input, int fromIndex)
    Lazily and iteratively matches input starting from fromIndex, skipping the skippable patterns, until the input is exhausted or matching failed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parse

      public T parse(String input)
      Parses input while skipping the skippable patterns around lexical tokens.
    • parse

      public T parse(String input, int fromIndex)
      Parses input starting from fromIndex while skipping patterns around lexical tokens.
    • parseToStream

      public Stream<T> parseToStream(String input)
      Parses input to a lazy stream while skipping the skippable patterns around lexical tokens.
    • parseToStream

      public Stream<T> parseToStream(String input, int fromIndex)
      Parses input starting from fromIndex to a lazy stream while skipping the skippable patterns around lexical tokens.
    • parseToStream

      public Stream<T> parseToStream(Reader input)
      Parses input reader to a lazy stream while skipping the skippable patterns around lexical tokens.

      UncheckedIOException will be thrown if the underlying reader throws.

      Characters are internally buffered, so you don't need to pass in BufferedReader.

    • probe

      public Stream<T> probe(String input)
      Lazily and iteratively matches input, 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

      public Stream<T> probe(String input, int fromIndex)
      Lazily and iteratively matches input starting from fromIndex, 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

      public Stream<T> probe(Reader input)
      Lazily and iteratively matches input reader, 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.

      UncheckedIOException will be thrown if the underlying reader throws.

      Characters are internally buffered, so you don't need to pass in BufferedReader.