Package org.jparsec

Class Api

java.lang.Object
org.jparsec.Api

public class Api extends Object
  • Constructor Details

    • Api

      public Api()
  • Method Details

    • anyChar

      public static Satisfy anyChar()

      Matches any single char.

    • anyOf

      public static Satisfy anyOf(Character... chars)

      Any of the enumerated chars.

    • c

      public static Satisfy c(Character ch)

      Captures single given char

    • whitespace

      public static Satisfy whitespace()

      Matches on java’s Character::isWhitespace for single char.

    • nonZeroDigit

      public static Satisfy nonZeroDigit()

      Single digit starting from '1'.

    • digit

      public static Satisfy digit()

      Single digit starting from '0'

    • letter

      public static Satisfy letter()

      Any alphabetic character.

    • alphaNum

      public static Satisfy alphaNum()

      Alphabetic characters plus digits

    • lower

      public static Satisfy lower()

      Alphabetic character lower case

    • upper

      public static Satisfy upper()

      Alphabetic character upper case.

    • satisfy

      public static Satisfy satisfy(Predicate<Character> pred)

      Applies predicate on single character and succeds if predicate succeeds.

    • range

      public static Satisfy range(Character start, Character end)

      Single character in between the range start..end

    • noneOf

      public static Satisfy noneOf(Character... inverseMatchers)

      Fails if any of the characters specified is matched.

    • choice

      public static <T, U> Matcher<Either<T,U>> choice(Matcher<T> c1, Matcher<U> c2)

      Succeds if any of the matchers succeeds.

    • choice

      public static <T, U, W> Matcher<Choice3<T,U,W>> choice(Matcher<T> c1, Matcher<U> c2, Matcher<W> c3)

      Succeds if any of the matchers succeeds.

    • choice

      public static <T, U, W, Z> Matcher<Choice4<T,U,W,Z>> choice(Matcher<T> c1, Matcher<U> c2, Matcher<W> c3, Matcher<Z> c4)

      Succeds if any of the matchers succeeds.

    • choice

      public static <T, U, W, Z, X> Matcher<Choice5<T,U,W,Z,X>> choice(Matcher<T> c1, Matcher<U> c2, Matcher<W> c3, Matcher<Z> c4, Matcher<X> c5)

      Succeds if any of the matchers succeeds.

    • choice

      public static <T, U, W, Z, X, G> Matcher<Choice6<T,U,W,Z,X,G>> choice(Matcher<T> c1, Matcher<U> c2, Matcher<W> c3, Matcher<Z> c4, Matcher<X> c5, Matcher<G> c6)

      Succeds if any of the matchers succeeds.

    • choice

      public static <T, U, W, Z, X, G, H> Matcher<Choice7<T,U,W,Z,X,G,H>> choice(Matcher<T> c1, Matcher<U> c2, Matcher<W> c3, Matcher<Z> c4, Matcher<X> c5, Matcher<G> c6, Matcher<H> c7)

      Succeds if any of the matchers succeeds.

    • seq

      public static <T, U> Seq.SeqX<Pair<T,U>> seq(Matcher<T> one, Matcher<U> two)

      Asserts all matchers succeed in order.

    • seq

      public static <T, U, W> Seq.SeqX<Tuple3<T,U,W>> seq(Matcher<T> one, Matcher<U> two, Matcher<W> three)

      Asserts all matchers succeed in order.

    • seq

      public static <T, U, W, Z> Seq.SeqX<Tuple4<T,U,W,Z>> seq(Matcher<T> one, Matcher<U> two, Matcher<W> three, Matcher<Z> four)

      Asserts all matchers succeed in order.

    • seq

      public static <T, U, W, Z, Y> Seq.SeqX<Tuple5<T,U,W,Z,Y>> seq(Matcher<T> one, Matcher<U> two, Matcher<W> three, Matcher<Z> four, Matcher<Y> five)

      Asserts all matchers succeed in order.

    • seq

      public static <T, U, W, Z, Y, X> Seq.SeqX<Tuple6<T,U,W,Z,Y,X>> seq(Matcher<T> one, Matcher<U> two, Matcher<W> three, Matcher<Z> four, Matcher<Y> five, Matcher<X> six)

      Asserts all matchers succeed in order.

    • seq

      public static <T, U, W, Z, Y, X, G> Seq.SeqX<Tuple7<T,U,W,Z,Y,X,G>> seq(Matcher<T> one, Matcher<U> two, Matcher<W> three, Matcher<Z> four, Matcher<Y> five, Matcher<X> six, Matcher<G> seven)

      Asserts all matchers succeed in order.

    • any

      @SafeVarargs public static <U> Matcher<U> any(Matcher<U>... matchers)

      Takes the first one of the succeeding matchers. All matchers have to wrap the same type.

    • many

      public static <U> Many<U> many(Matcher<U> inner)

      Zero or more occurences of matcher. Always succeeds.

    • some

      public static <U> Many<U> some(Matcher<U> inner)

      One or more occurences of matcher. Fails on zero occurences.

    • times

      public static <U> Times<U> times(Matcher<U> inner, int times)

      Matches exactly X occurences of matcher.

    • times

      public static <U> Times<U> times(Matcher<U> inner, int from, int to)

      For success matcher has to be matched between from and to times.

    • opt

      public static <T> Opt<T> opt(Matcher<T> inner)

      Optional occurence of the matcher. Always succeds.

    • c

      public static Str c(String pattern)

      Captures exact string.

    • stringIgnoreCase

      public static Str stringIgnoreCase(String pattern)

      Matches a string ignoring the case sensitivity.

    • spaces

      public static Spaces spaces(Character... chrs)

      Takes one or more specified whitespaces. If none are specified then the Java defaults are applied.

    • comment

      public static SinglelineComment comment(String act)

      Takes a single line comment starting with an activator string.

    • multilineComment

      public static MultilineComment multilineComment(String start, String end)

      Takes multiline comment starting with start and ending with end activators.

    • lexeme

      public static <T> Lexeme<T> lexeme(Matcher<T> inner, Matcher<?> ws)

      Wraps first rule and takes up second rule to exhaustion. Second rule is typically a whitespace. Only first rule is returned.

    • sepBy

      public static <V, U> Matcher<List<V>> sepBy(Matcher<V> inner, Matcher<U> sep)

      Zero or more occurences of first rule separated by second rule.

    • not

      public static <T> Matcher<Empty> not(Matcher<T> inner)

      Fails if matcher succeeds.

    • recursive

      public static <T> Recursive<T> recursive()

      Allows to refer to itself before setting. Typically you handle recurrence by using recursive() refering to it by other rules and finally setting it with set() method.

    • indent

      public static <T> Indent<T> indent(Matcher<T> inner, String pattern)

      Applies scope of to inner rule and increments the indentation. The indentation is executed on newlines nl()

    • nl

      public static Newline nl()

      Newline that is indentation sensitive.

    • input

      public static Context input(String text)

      Convenience method for wrapping text in Context.

    • eos

      public static Eos eos()

      By default rules take only parts in greedy way leaving off the rest and succeeding. By applying eos() we can assert that text is parsed from start to finish.