Class

org.bitbucket.inkytonik.kiama.parsing

Parsers

Related Doc: package parsing

Permalink

class Parsers extends ParsersBase with VectorRepetitionParsers

Parser combinators that use vectors to represent repetitive constructs.

Source
Parsers.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Parsers
  2. VectorRepetitionParsers
  3. ParsersBase
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Parsers(positions: Positions)

    Permalink

Type Members

  1. sealed abstract class Answer[T] extends AnyRef

    Permalink

    Parsing answers.

    Parsing answers.

    Definition Classes
    ParsersBase
  2. trait CCOps[CC[_] <: Seq[_]] extends AnyRef

    Permalink

    Interface for operations needed for repetition collections.

    Interface for operations needed for repetition collections.

    Definition Classes
    ParsersBase
  3. case class Head(rule: Rule, involvedSet: Set[Rule], evalSet: Set[Rule]) extends Product with Serializable

    Permalink

    Information about an active instance of left recursion.

    Information about an active instance of left recursion.

    Definition Classes
    ParsersBase
  4. case class LR[T](seed: ParseResult[T], rule: Rule, head: Head, next: LR[T]) extends Answer[T] with Product with Serializable

    Permalink

    An answer that is a left recursion record.

    An answer that is a left recursion record.

    Definition Classes
    ParsersBase
  5. class Marker extends AnyRef

    Permalink

    A marker of a position.

    A marker of a position. Instaneces of this are used as placeholders when there are no other suitable values associated with a parse position.

    Definition Classes
    ParsersBase
  6. class PackratParser[T] extends Parser[T] with Rule

    Permalink

    A parser that is a memoising, left recursion-detecting encapsulation of a normal parser that returns a value of a particular type.

    A parser that is a memoising, left recursion-detecting encapsulation of a normal parser that returns a value of a particular type. This type of parser must be used if any of the alternatives are left recursive. Otherwise a plain Parser can be used if memoisation is not desired.

    Note that it is non-trivial (impossible?) to combine this class with Parser. We need the latter to be covariant but this class can't be because T occurs in an invariant position in MemoEntry.

    Definition Classes
    ParsersBase
  7. abstract class Parser[+T] extends (Input) ⇒ ParseResult[T]

    Permalink

    A parser is a function from a string to a parser result.

    A parser is a function from a string to a parser result. This kind of parser cannot handle left recursive alternatives and does not memoise its results so it may repeat work. If those properties are desired use the PackratParser type instead.

    Definition Classes
    ParsersBase
  8. implicit class PostfixParserCombinators[T] extends AnyRef

    Permalink

    Adds postfix * and + to Parser class (vector version).

    Adds postfix * and + to Parser class (vector version).

    Definition Classes
    VectorRepetitionParsers
  9. case class Resolution[T](result: ParseResult[T]) extends Answer[T] with Product with Serializable

    Permalink

    An answer that is a resolved parser result.

    An answer that is a resolved parser result.

    Definition Classes
    ParsersBase
  10. trait Rule extends AnyRef

    Permalink

    Common supertype for all rules (ie regardless of result type).

    Common supertype for all rules (ie regardless of result type).

    Definition Classes
    ParsersBase
  11. case class ~[+T, +U](_1: T, _2: U) extends Product with Serializable

    Permalink

    Special tuple class to match sequence combinator.

    Special tuple class to match sequence combinator.

    Definition Classes
    ParsersBase

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def Parser[T](f: (Input) ⇒ ParseResult[T]): Parser[T]

    Permalink

    Convenience method for making a parser out of its body function, including adding support for whitespace prefix skipping and position recording.

    Convenience method for making a parser out of its body function, including adding support for whitespace prefix skipping and position recording. All parsers should be created using this method so that they share the book-keeping.

    Definition Classes
    ParsersBase
  5. object VectorOps extends (VectorRepetitionParsers.this)#CCOps[Vector]

    Permalink
    Definition Classes
    VectorRepetitionParsers
  6. def any: Parser[Char]

    Permalink

    A parser that matches any character, failing if the end of input is reached.

    A parser that matches any character, failing if the end of input is reached.

    Definition Classes
    ParsersBase
  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def commit[U](p: ⇒ Parser[U]): Parser[U]

    Permalink

    Wrap p so that its failures become errors.

    Wrap p so that its failures become errors. See also nocut.

    Definition Classes
    ParsersBase
  10. implicit def constToTupleFunction2[A, B, X](x: (A, B) ⇒ X): (~[A, B]) ⇒ X

    Permalink

    Convenience conversion to allow arity two functions to be used directly in tree construction actions.

    Convenience conversion to allow arity two functions to be used directly in tree construction actions.

    Definition Classes
    ParsersBase
  11. implicit def constToTupleFunction3[A, B, C, X](x: (A, B, C) ⇒ X): (~[~[A, B], C]) ⇒ X

    Permalink

    Convenience conversion to allow arity three functions to be used directly in tree construction actions.

    Convenience conversion to allow arity three functions to be used directly in tree construction actions.

    Definition Classes
    ParsersBase
  12. implicit def constToTupleFunction4[A, B, C, D, X](x: (A, B, C, D) ⇒ X): (~[~[~[A, B], C], D]) ⇒ X

    Permalink

    Convenience conversion to allow arity four functions to be used directly in tree construction actions.

    Convenience conversion to allow arity four functions to be used directly in tree construction actions.

    Definition Classes
    ParsersBase
  13. implicit def constToTupleFunction5[A, B, C, D, E, X](x: (A, B, C, D, E) ⇒ X): (~[~[~[~[A, B], C], D], E]) ⇒ X

    Permalink

    Convenience conversion to allow arity five functions to be used directly in tree construction actions.

    Convenience conversion to allow arity five functions to be used directly in tree construction actions.

    Definition Classes
    ParsersBase
  14. implicit def constToTupleFunction6[A, B, C, D, E, F, X](x: (A, B, C, D, E, F) ⇒ X): (~[~[~[~[~[A, B], C], D], E], F]) ⇒ X

    Permalink

    Convenience conversion to allow arity six functions to be used directly in tree construction actions.

    Convenience conversion to allow arity six functions to be used directly in tree construction actions.

    Definition Classes
    ParsersBase
  15. lazy val constrainedInt: Parser[Int]

    Permalink

    Parse digit strings that are constrained to fit into an Int value.

    Parse digit strings that are constrained to fit into an Int value. If the digit string is too big, a parse error results.

    Definition Classes
    ParsersBase
  16. def elem(message: String, p: (Char) ⇒ Boolean): Parser[Char]

    Permalink

    A parser that accepts just those characters that pass the given predicate.

    A parser that accepts just those characters that pass the given predicate. The message is used to describe what was expected if an error occurs.

    Definition Classes
    ParsersBase
  17. def elem(ch: Char): Parser[Char]

    Permalink

    A parser that accepts just the given character.

    A parser that accepts just the given character.

    Definition Classes
    ParsersBase
  18. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  20. def error(message: String): Parser[Nothing]

    Permalink

    A parser that always errors with the given message.

    A parser that always errors with the given message.

    Definition Classes
    ParsersBase
  21. def failure(message: String): Parser[Nothing]

    Permalink

    A parser that always fails with the given message.

    A parser that always fails with the given message.

    Definition Classes
    ParsersBase
  22. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  23. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  24. def grep[T, CC[_] <: Seq[_]](p: ⇒ Parser[T])(ops: CCOps[CC]): Parser[CC[T]]

    Permalink

    Generic repetition zero or more times.

    Generic repetition zero or more times.

    Definition Classes
    ParsersBase
  25. def grep1[T, CC[_] <: Seq[_]](p: ⇒ Parser[T])(ops: CCOps[CC]): Parser[CC[T]]

    Permalink

    Generic repetition one or more times.

    Generic repetition one or more times.

    Definition Classes
    ParsersBase
  26. def grep1sep[T, CC[_] <: Seq[_]](p: ⇒ Parser[T], q: ⇒ Parser[Any])(ops: CCOps[CC]): Parser[CC[T]]

    Permalink

    Generic repetition one or more times with separators.

    Generic repetition one or more times with separators.

    Definition Classes
    ParsersBase
  27. def grepsep[T, CC[_] <: Seq[_]](p: ⇒ Parser[T], q: ⇒ Parser[Any])(ops: CCOps[CC]): Parser[CC[T]]

    Permalink

    Generic repetition zero or more times with separators.

    Generic repetition zero or more times with separators.

    Definition Classes
    ParsersBase
  28. def guard[T](p: ⇒ Parser[T]): Parser[T]

    Permalink

    A parser that succeeds iff its argument parser succeeds, but consumes no input in any circumstances.

    A parser that succeeds iff its argument parser succeeds, but consumes no input in any circumstances.

    Definition Classes
    ParsersBase
  29. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  30. var heads: HashMap[Input, Head]

    Permalink

    Map between left input positions and active left recursion instances.

    Map between left input positions and active left recursion instances.

    Definition Classes
    ParsersBase
  31. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  32. def keywords(ext: Regex, kws: List[String]): Parser[String]

    Permalink

    Parser for keywords.

    Parser for keywords. The list of string arguments gives the text of the keywords in a language. The regular expression gives the possible extension of the keyword to stop the keyword being seen as an identifier instead. For example, the keyword list might contain "begin" and "end" and the extension regular expression might be [^a-zA-Z0-9]. Thus, begin followed by something other than a letter or digit is a keyword, but beginfoo8 is an identifier. This parser succeeds if any of the keywords is present, provided that it's not immediately followed by something that extends it.

    Definition Classes
    ParsersBase
  33. lazy val latestNoSuccess: DynamicVariable[Option[NoSuccess]]

    Permalink

    Record lack of success so that we can nicely handle the case where a phrase doesn't parse when looking for the end of input but there was a later lack of success for some other reason.

    Record lack of success so that we can nicely handle the case where a phrase doesn't parse when looking for the end of input but there was a later lack of success for some other reason.

    Definition Classes
    ParsersBase
  34. implicit def literal(s: String): Parser[String]

    Permalink

    A parser that matches a literal string after skipping any whitespace.

    A parser that matches a literal string after skipping any whitespace. The form of the latter is defined by the whitespace parser.

    Definition Classes
    ParsersBase
  35. def mark[T](p: ⇒ Parser[String]): Parser[Marker]

    Permalink

    Mark a string parser so that its value is discarded but a marker is returned instead.

    Mark a string parser so that its value is discarded but a marker is returned instead. That return value can then be used to set the position of another value. We can't use the string value itself since we are not guaranteed to have reference equality on strings.

    Definition Classes
    ParsersBase
  36. implicit def memo[T](parser: ⇒ Parser[T]): PackratParser[T]

    Permalink

    (Implicit) conversion of non-memoising parser into a memoising one.

    (Implicit) conversion of non-memoising parser into a memoising one.

    Definition Classes
    ParsersBase
  37. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  38. def nocut[T](p: ⇒ Parser[T]): Parser[T]

    Permalink

    Suppress cuts in the parser p.

    Suppress cuts in the parser p. I.e., errors produced by p are propagated as failures instead. See also commit.

    Definition Classes
    ParsersBase
  39. def not[T](p: ⇒ Parser[T]): Parser[Unit]

    Permalink

    Invert the result of a parser without consuming any input.

    Invert the result of a parser without consuming any input.

    Definition Classes
    ParsersBase
  40. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  41. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  42. def opt[T](p: ⇒ Parser[T]): Parser[Option[T]]

    Permalink

    Optional parsing.

    Optional parsing.

    Definition Classes
    ParsersBase
  43. def parse[T](p: Parser[T], source: Source): ParseResult[T]

    Permalink

    Run a parser on a string to obtain its result.

    Run a parser on a string to obtain its result.

    Definition Classes
    ParsersBase
  44. def parseAll[T](p: Parser[T], source: Source): ParseResult[T]

    Permalink

    Run a parser on all of a string to obtain its result.

    Run a parser on all of a string to obtain its result.

    Definition Classes
    ParsersBase
  45. implicit def parseResultToTuple2[A, B](p: Parser[~[A, B]]): Parser[(A, B)]

    Permalink

    Convenience conversion to lift parsers that return 2-tilde-tuples to parsers that return regular 2-tuples.

    Convenience conversion to lift parsers that return 2-tilde-tuples to parsers that return regular 2-tuples.

    Definition Classes
    ParsersBase
  46. implicit def parseResultToTuple3[A, B, C](p: Parser[~[~[A, B], C]]): Parser[(A, B, C)]

    Permalink

    Convenience conversion to lift parsers that return 3-tilde-tuples to parsers that return regular 3-tuples.

    Convenience conversion to lift parsers that return 3-tilde-tuples to parsers that return regular 3-tuples.

    Definition Classes
    ParsersBase
  47. implicit def parseResultToTuple4[A, B, C, D](p: Parser[~[~[~[A, B], C], D]]): Parser[(A, B, C, D)]

    Permalink

    Convenience conversion to lift parsers that return 4-tilde-tuples to parsers that return regular 4-tuples.

    Convenience conversion to lift parsers that return 4-tilde-tuples to parsers that return regular 4-tuples.

    Definition Classes
    ParsersBase
  48. implicit def parseResultToTuple5[A, B, C, D, E](p: Parser[~[~[~[~[A, B], C], D], E]]): Parser[(A, B, C, D, E)]

    Permalink

    Convenience conversion to lift parsers that return 5-tilde-tuples to parsers that return regular 5-tuples.

    Convenience conversion to lift parsers that return 5-tilde-tuples to parsers that return regular 5-tuples.

    Definition Classes
    ParsersBase
  49. implicit def parseResultToTuple6[A, B, C, D, E, F](p: Parser[~[~[~[~[~[A, B], C], D], E], F]]): Parser[(A, B, C, D, E, F)]

    Permalink

    Convenience conversion to lift parsers that return 6-tilde-tuples to parsers that return regular 6-tuples.

    Convenience conversion to lift parsers that return 6-tilde-tuples to parsers that return regular 6-tuples.

    Definition Classes
    ParsersBase
  50. def parseWhitespace(in: Input): ParseResult[Any]

    Permalink

    If we are parsing whitespace already, succeed with no progress so that we don't recurse.

    If we are parsing whitespace already, succeed with no progress so that we don't recurse. If we are not already parsing whitespace, then apply the whitespace parser, swallowing any errors from it unless they occur at the end of the input. In other words, an error not at the end is treated as the absence of whitespace.

    Definition Classes
    ParsersBase
  51. var parsingWhitespace: Boolean

    Permalink

    Are we currently parsing whitespace?

    Are we currently parsing whitespace?

    Definition Classes
    ParsersBase
  52. def phrase[T](p: ⇒ Parser[T]): Parser[T]

    Permalink

    Phrases, i.e., parse and succeed with no input remaining, except possibly for whitespace at the end.

    Phrases, i.e., parse and succeed with no input remaining, except possibly for whitespace at the end. If there is another later failure, prefer it over the failure due to end of input being expected since the later one is usually more informative.

    Definition Classes
    ParsersBase
  53. implicit def regex(r: Regex): Parser[String]

    Permalink

    A parser that matches a regex string after skipping any whitespace.

    A parser that matches a regex string after skipping any whitespace. The form of the latter is defined by the whitespace parser.

    Definition Classes
    ParsersBase
  54. def rep[T](p: ⇒ Parser[T]): Parser[Vector[T]]

    Permalink

    Repetition zero or more times (vector version).

    Repetition zero or more times (vector version).

    Definition Classes
    VectorRepetitionParsers
  55. def rep1[T](p: ⇒ Parser[T]): Parser[Vector[T]]

    Permalink

    Repetition one or more times (vector version).

    Repetition one or more times (vector version).

    Definition Classes
    VectorRepetitionParsers
  56. def rep1sep[T](p: ⇒ Parser[T], q: ⇒ Parser[Any]): Parser[Vector[T]]

    Permalink

    Repetition one or more times with separators (vector version)

    Repetition one or more times with separators (vector version)

    Definition Classes
    VectorRepetitionParsers
  57. def repsep[T](p: ⇒ Parser[T], q: ⇒ Parser[Any]): Parser[Vector[T]]

    Permalink

    Repetition zero or more times with separators (vector version)

    Repetition zero or more times with separators (vector version)

    Definition Classes
    VectorRepetitionParsers
  58. def stringToInt(s: String): Either[Int, String]

    Permalink

    Convert the digit string s to an Int if it's in range, but return an error message if it's too big.

    Convert the digit string s to an Int if it's in range, but return an error message if it's too big.

    Definition Classes
    ParsersBase
  59. def success[T](v: ⇒ T): Parser[T]

    Permalink

    Succeed with a given value consuming no non-whitespace input.

    Succeed with a given value consuming no non-whitespace input. The value is evaluated each time this parser is used.

    Definition Classes
    ParsersBase
  60. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  61. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  62. def updateLatestNoSuccess[T](res: NoSuccess): ParseResult[T]

    Permalink
    Definition Classes
    ParsersBase
  63. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  64. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  65. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  66. def whitespace: Parser[Any]

    Permalink

    A parser that skips whitespace (default: sequences of zero or more whitespace characters).

    A parser that skips whitespace (default: sequences of zero or more whitespace characters). This definition can be overridden as long as the new definition succeeds at the end of the input.

    Definition Classes
    ParsersBase
  67. def wrap[T, U](p: ⇒ Parser[T], f: (T) ⇒ Either[U, String]): Parser[U]

    Permalink

    Wrap a parser p that produces a value of type T to produce a parser returning values of type U.

    Wrap a parser p that produces a value of type T to produce a parser returning values of type U.

    The function f is responsible for converting the T value into either a U value or a string that indicates what went wrong. In the latter case, the resulting parser will error at the original position with the message, ignoring any other errors at that position. Failures or errors of p will be lifted to the returned type.

    Definition Classes
    ParsersBase

Inherited from VectorRepetitionParsers

Inherited from ParsersBase

Inherited from AnyRef

Inherited from Any

Ungrouped