kiama.parsing

trait PackratParsers

[source: kiama/parsing/PackratParsers.scala]

trait PackratParsers
extends Parsers
Parsers that use the packrat parsing approach to memoise parsing results, including support for left recursive grammar rules. The algorithms used here are from "Packrat parsers can support left recursion" by Warth, Douglass and Millstein, ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, 2008.
Direct Known Subclasses:
CharPackratParsers

Value Summary
var LRStack : LR[Any]
Left recursion stack.
var heads : scala.collection.mutable.HashMap[scala.util.parsing.input.Reader, Head]
Map between left input positions and active left recursion instances.
Values and Variables inherited from Parsers
any
Method Summary
implicit def memo [T](parser : => Parser[T]) : MemoParser[T]
(Implicit) conversion of non-memoising parser into a memoising one.
def rep1 [T](p : => MemoParser[T]) : MemoParser[scala.List[T]]
Construct a parser that parses one or more occurrences of what p parses. Collect the result values in a list. Because these parsers are able to deal with left recursion and the iteration used to handle left recursion is more efficient than a general stack-based right recursion, left recursion is used here.
Methods inherited from Parsers
Parser, success, failure, accept, acceptIf, opt, rep, rep1, repN, repsep, rep1sep, phrase, and, not
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Class Summary
abstract class Answer [T] extends AnyRef
Parsing answers.
case class Head (val rule : Rule, val involvedSet : scala.collection.mutable.Set[Rule], val evalSet : scala.collection.mutable.Set[Rule]) extends scala.Product
Information about an active instance of left recursion.
case class LR [T](val seed : ParseResult[T], val rule : Rule, val head : Head, val next : LR[Any]) extends Answer[T] with scala.Product
An answer that is a left recursion record.
class MemoParser [T](body : => Parser[T]) extends Parser[T] with Rule
A typed rule is a memoising, left recursion-detecting encapsulation of a parser that returns a value of a particular type.
case class Result [T](val result : ParseResult[T]) extends Answer[T] with scala.Product
An answer that is a parser result.
trait Rule extends AnyRef
Common supertype for all rules (ie regardless of result type).
Value Details
var heads : scala.collection.mutable.HashMap[scala.util.parsing.input.Reader, Head]
Map between left input positions and active left recursion instances.

var LRStack : LR[Any]
Left recursion stack.

Method Details
def rep1[T](p : => MemoParser[T]) : MemoParser[scala.List[T]]
Construct a parser that parses one or more occurrences of what p parses. Collect the result values in a list. Because these parsers are able to deal with left recursion and the iteration used to handle left recursion is more efficient than a general stack-based right recursion, left recursion is used here.

implicit def memo[T](parser : => Parser[T]) : MemoParser[T]
(Implicit) conversion of non-memoising parser into a memoising one.