trait Parsers extends Syntaxes with Parsing with Enumeration with PrettyPrinting with Operators with Debug
- Grouped
- Alphabetic
- By Inheritance
- Parsers
- Debug
- Operators
- PrettyPrinting
- Enumeration
- Parsing
- Syntaxes
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
sealed
trait
Associativity extends AnyRef
Associativity of an operator.
Associativity of an operator.
- Definition Classes
- Operators
-
case class
Level[Op](operator: (Operators.this)#Syntax[Op], associativity: (Operators.this)#Associativity) extends Product with Serializable
Represents a precedence level with a syntax for the various
operator
s of that level and an associativity.Represents a precedence level with a syntax for the various
operator
s of that level and an associativity.- Definition Classes
- Operators
-
implicit
class
LevelDecorator[Op] extends AnyRef
Implicitly decorates an
operator
syntax to add anis
method that indicates the associativity of the operator.Implicitly decorates an
operator
syntax to add anis
method that indicates the associativity of the operator.Example
val level = div | times is LeftAssociative
- Definition Classes
- Operators
-
abstract
type
Kind
Type of kinds.
Type of kinds.
- Definition Classes
- Syntaxes
-
type
Mark = String
Type of markings.
Type of markings.
- Definition Classes
- Syntaxes
-
type
RecId = Int
Unique identifier for Recursive syntaxes.
Unique identifier for Recursive syntaxes.
- Definition Classes
- Syntaxes
-
abstract
type
Token
Type of tokens.
Type of tokens.
- Definition Classes
- Syntaxes
-
sealed
trait
Conflict extends AnyRef
Describes a LL(1) conflict.
Describes a LL(1) conflict.
- Definition Classes
- Parsing
-
case class
ConflictException(conflicts: Set[(Parsing.this)#Conflict]) extends Exception with Product with Serializable
Indicates that a syntax is not LL(1) due to various conflicts.
Indicates that a syntax is not LL(1) due to various conflicts.
- Definition Classes
- Parsing
-
sealed
trait
ParseResult[A] extends AnyRef
Result of parsing.
Result of parsing.
- Definition Classes
- Parsing
-
case class
Parsed[A](value: A, rest: (Parsing.this)#Parser[A]) extends (Parsing.this)#ParseResult[A] with Product with Serializable
Indicates that the input has been fully parsed, resulting in a
value
.Indicates that the input has been fully parsed, resulting in a
value
.A parser for subsequent input is also provided.
- value
The value produced.
- rest
Parser for more input.
- Definition Classes
- Parsing
-
sealed
trait
Parser[A] extends AnyRef
LL(1) parser.
LL(1) parser.
- Definition Classes
- Parsing
-
case class
Properties[A](nullable: Option[A], first: Set[(Parsing.this)#Kind], shouldNotFollow: Set[(Parsing.this)#Kind], conflicts: Set[(Parsing.this)#Conflict]) extends Product with Serializable
Contains properties of syntaxes.
Contains properties of syntaxes.
- nullable
A value associated to the empty string, if any.
- first
The set of token kinds that can start valid sequences.
- shouldNotFollow
The set of token kinds that should not follow in sequence.
- conflicts
The set of LL(1) conflicts of the syntax.
- Definition Classes
- Parsing
-
case class
UnexpectedEnd[A](rest: (Parsing.this)#Parser[A]) extends (Parsing.this)#ParseResult[A] with Product with Serializable
Indicates that end of input was unexpectedly encountered.
Indicates that end of input was unexpectedly encountered.
The
syntax
for subsequent input is provided.- Definition Classes
- Parsing
-
case class
UnexpectedToken[A](token: (Parsing.this)#Token, rest: (Parsing.this)#Parser[A]) extends (Parsing.this)#ParseResult[A] with Product with Serializable
Indicates that the provided
token
was not expected at that point.Indicates that the provided
token
was not expected at that point.The parser at the point of error is returned.
- token
The token at fault.
- rest
Parser at the point of error.
- Definition Classes
- Parsing
-
trait
PrettyPrinter[A] extends AnyRef
Pretty printer of values.
Pretty printer of values.
- Definition Classes
- PrettyPrinting
-
case class
Skip(syntax: Syntax[Unit]) extends Product with Serializable
Wrapper around a
Syntax
indicating that values from the innersyntax
should be ignored when building up sequences using~
.Wrapper around a
Syntax
indicating that values from the innersyntax
should be ignored when building up sequences using~
.- syntax
The wrapped syntax.
- Definition Classes
- Syntaxes
-
sealed
trait
Syntax[A] extends AnyRef
Represents a syntax.
Represents a syntax.
Acts as both a parser and a pretty printer.
- A
the type of values that can be produced or printed.
- Definition Classes
- Syntaxes
-
trait
Uninteresting[A] extends AnyRef
Typeclass to denote that values of a given type are uninteresting and can be safely ignored while describing a syntax.
Typeclass to denote that values of a given type are uninteresting and can be safely ignored while describing a syntax.
- Definition Classes
- Syntaxes
- Annotations
- @implicitNotFound( ... )
-
trait
UnsafeImplicits extends AnyRef
Low priority implicits.
Low priority implicits. Contains an instance for Uninteresting for every type.
- Definition Classes
- Syntaxes
Abstract Value Members
Concrete Value Members
-
object
Enumerator
Factory of iterators over sequences accepted by a syntax.
Factory of iterators over sequences accepted by a syntax.
- Definition Classes
- Enumeration
-
object
LeftAssociative extends (Operators.this)#Associativity with Product with Serializable
Left-associativity.
Left-associativity.
- Definition Classes
- Operators
-
object
RightAssociative extends (Operators.this)#Associativity with Product with Serializable
Right-associativity.
Right-associativity.
- Definition Classes
- Operators
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
accept[A](kind: Kind)(function: PartialFunction[Token, A], inverse: (A) ⇒ Seq[Token] = (x: A) => Seq()): Syntax[A]
Syntax that describes a single token of the provided
kind
, and that directly applies a function on the successfully parsed token.Syntax that describes a single token of the provided
kind
, and that directly applies a function on the successfully parsed token.- Definition Classes
- Syntaxes
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
debug[A](syntax: Syntax[A], showTrails: Boolean = true, ansi: Boolean = true): Unit
Prints a report of LL(1) conflicts in the syntax.
Prints a report of LL(1) conflicts in the syntax.
- Definition Classes
- Debug
-
def
debugString[A](syntax: Syntax[A], showTrails: Boolean = true, ansi: Boolean = true): String
Returns a report of LL(1) conflicts in the syntax.
Returns a report of LL(1) conflicts in the syntax.
- Definition Classes
- Debug
-
def
elem(kind: Kind): Syntax[Token]
Syntax that describes a single token of the provided
kind
.Syntax that describes a single token of the provided
kind
.- Definition Classes
- Syntaxes
-
def
epsilon[A](value: A): Syntax[A]
Syntax that produces the given
value
to the empty sequence of tokens.Syntax that produces the given
value
to the empty sequence of tokens.- Definition Classes
- Syntaxes
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
failure[A]: Syntax[A]
Empty syntax.
Empty syntax.
- Definition Classes
- Syntaxes
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
infixLeft[Op, A](elem: Syntax[A], op: Syntax[Op])(function: (A, Op, A) ⇒ A, inverse: PartialFunction[A, (A, Op, A)] = PartialFunction.empty): Syntax[A]
Syntax that represents repetitions of
elem
separated by left-associativeop
.Syntax that represents repetitions of
elem
separated by left-associativeop
. The value returned is reduced left-to-right.Example
val binaryOp: Syntax[Operator] = ... val operand: Syntax[Expr] = ... val operationExpr = infixLeft(operand, binaryOp) { // Describes how to turn two values and an operator into a value. case (lhs, op, rhs) => BinaryExpr(op, lhs, rhs) }
With inverse function, for pretty printing support:
val binaryOp: Syntax[Operator] = ... val operand: Syntax[Expr] = ... val operationExpr = infixLeft(operand, binaryOp)({ // Describes how to turn two values and an operator into a value. case (lhs, op, rhs) => BinaryExpr(op, lhs, rhs) }, { // Describes how to turn a `BinaryExpr` back to its components. case BinaryExpr(op, lhs, rhs) => (lhs, op, rhs) })
- elem
Syntax for the operands.
- op
Syntax for the operators.
- function
Function to apply an operation.
- inverse
Function to reverse an operation.
- Definition Classes
- Operators
-
def
infixRight[Op, A](elem: Syntax[A], op: Syntax[Op])(function: (A, Op, A) ⇒ A, inverse: PartialFunction[A, (A, Op, A)] = PartialFunction.empty): Syntax[A]
Syntax that represents repetitions of
elem
separated by right-associativeop
.Syntax that represents repetitions of
elem
separated by right-associativeop
. The value returned is reduced right-to-left.Example
val binaryOp: Syntax[Operator] = ... val operand: Syntax[Expr] = ... val operationExpr = infixRight(operand, binaryOp) { // Describes how to turn two values and an operator into a value. case (lhs, op, rhs) => BinaryExpr(op, lhs, rhs) }
With inverse function, for pretty printing support:
val binaryOp: Syntax[Operator] = ... val operand: Syntax[Expr] = ... val operationExpr = infixRight(operand, binaryOp)({ // Describes how to turn two values and an operator into a value. case (lhs, op, rhs) => BinaryExpr(op, lhs, rhs) }, { // Describes how to turn a `BinaryExpr` back to its components. case BinaryExpr(op, lhs, rhs) => (lhs, op, rhs) })
- elem
Syntax for the operands.
- op
Syntax for the operators.
- function
Function to apply an operation.
- inverse
Function to reverse an operation. *
- Definition Classes
- Operators
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
many[A](rep: Syntax[A], mark: Option[Mark] = None): Syntax[Seq[A]]
Syntax that represents 0 or more repetitions of the
rep
syntax.Syntax that represents 0 or more repetitions of the
rep
syntax.- Definition Classes
- Syntaxes
-
def
many1[A](rep: Syntax[A], mark: Option[Mark] = None): Syntax[Seq[A]]
Syntax that represents 1 or more repetitions of the
rep
syntax.Syntax that represents 1 or more repetitions of the
rep
syntax.- Definition Classes
- Syntaxes
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
oneOf[A](syntaxes: Syntax[A]*): Syntax[A]
Syntax that represents the disjunction of several
syntaxes
.Syntax that represents the disjunction of several
syntaxes
.- Definition Classes
- Syntaxes
-
def
operators[Op, A](elem: Syntax[A])(levels: Level[Op]*)(function: (A, Op, A) ⇒ A, inverse: PartialFunction[A, (A, Op, A)] = PartialFunction.empty): Syntax[A]
Syntax that represents repetitions of
elem
separated by infix operators.Syntax that represents repetitions of
elem
separated by infix operators.The operators in earlier levels are considered to bind tighter than those in later levels.
Example
val andOp: Syntax[Operator] val orOp: Syntax[Operator] val implyOr: Syntax[Operator] val operand: Syntax[Expr] val operationExpr = operators(operand)( // The "and" operation binds the strongest. andOp is LeftAssociative, // Then, the "or" operation. orOp is LeftAssociative, // Finally, the "imply" operation, which is right associative. implyOr is RightAssociative )({ // Defines how to turn two values and an operator into a value. case (lhs, op, rhs) => BinaryExpr(op, lhs, rhs) }, { // Optionally, defines how to turn a value back into its components. // This part is only needed if you want to support pretty printing. case BinaryExpr(op, lhs, rhs) => (lhs, op, rhs) })
If multiple operators share the same priority level, you can simply combine them using
|
before specifying the associativity:val operationExpr = operators(operand)( // First, multiplication and division, at the same priority level. timesOp | divOp is LeftAssociative, // Then, addition and substraction, at the next priority level. plusOp | minusOp is LeftAssociative )({ case (lhs, op, rhs) => BinaryExpr(op, lhs, rhs) }, { case BinaryExpr(op, lhs, rhs) => (lhs, op, rhs) })
- elem
Syntax for the operands.
- levels
Operators (with associativity), in decreasing priority.
- function
Function to apply an operation.
- inverse
Function to reverse an operation.
- Definition Classes
- Operators
-
def
opt[A](syntax: Syntax[A]): Syntax[Option[A]]
Syntax that represents 0 or 1 instances of the
syntax
.Syntax that represents 0 or 1 instances of the
syntax
.- Definition Classes
- Syntaxes
-
def
postfixes[Op, A](elem: Syntax[A], op: Syntax[Op])(function: (A, Op) ⇒ A, inverse: PartialFunction[A, (A, Op)] = PartialFunction.empty): Syntax[A]
Syntax that represents
elem
postfixed by any number ofop
.Syntax that represents
elem
postfixed by any number ofop
.Operators are applied left-to-right.
Example
val simpleExpr: Syntax[Expr] = ... val unaryOps: Syntax[Operator] = ... val postfixedExpr = postfixes(simpleExpr, unaryOps) { // Defines how to convert an `expr` and an `op` into a `Unary` expression. case (expr, op) => Unary(op, expr) }
With inverse function, for pretty printing support:
val simpleExpr: Syntax[Expr] = ... val unaryOps: Syntax[Operator] = ... val postfixedExpr = postfixes(simpleExpr, unaryOps)({ // Defines how to convert an `expr` and an `op` into a `Unary` expression. case (expr, op) => Unary(op, expr) }, { // Defines how to convert a `Unary` expression into its components. case Unary(op, expr) => (expr, op) })
- elem
Syntax for the operands.
- op
Syntax for the operators.
- function
Function to apply an operation.
- inverse
Function to reverse an operation.
- Definition Classes
- Operators
-
def
prefixes[Op, A](op: Syntax[Op], elem: Syntax[A])(function: (Op, A) ⇒ A, inverse: PartialFunction[A, (Op, A)] = PartialFunction.empty): Syntax[A]
Syntax that represents
elem
prefixed by any number ofop
.Syntax that represents
elem
prefixed by any number ofop
.Operators are applied right-to-left.
Example
val simpleExpr: Syntax[Expr] = ... val unaryOps: Syntax[Operator] = ... val prefixedExpr = prefixes(unaryOps, simpleExpr) { // Defines how to convert an `op` and an `expr` into an `expr`. case (op, expr) => Unary(op, expr) }
With inverse function, for pretty printing support:
val simpleExpr: Syntax[Expr] = ... val unaryOps: Syntax[Operator] = ... val prefixedExpr = prefixes(unaryOps, simpleExpr)({ // Defines how to convert an `op` and an `expr` into a `Unary` expression. case (op, expr) => Unary(op, expr) }, { // Defines how to convert a `Unary` expression into its components. case Unary(op, expr) => (op, expr) })
- op
Syntax for the operators.
- elem
Syntax for the operands.
- function
Function to apply an operation.
- inverse
Function to reverse an operation.
- Definition Classes
- Operators
-
def
recursive[A](syntax: ⇒ Syntax[A]): Syntax[A]
Indicates that the syntax can refer to itself within its body.
Indicates that the syntax can refer to itself within its body.
- Definition Classes
- Syntaxes
-
def
rep1sep[A, B](rep: Syntax[A], sep: Syntax[B]): Syntax[Seq[A]]
[use case] Syntax that represents 1 or more repetitions of the
rep
syntax, separated bysep
. -
def
repsep[A, B](rep: Syntax[A], sep: Syntax[B]): Syntax[Seq[A]]
[use case] Syntax that represents 0 or more repetitions of the
rep
syntax, separated bysep
. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
implicit
def
syntaxToLL1Properties[A](syntax: Syntax[A]): Properties[A]
Decorates syntaxes with methods for LL(1) properties.
Decorates syntaxes with methods for LL(1) properties.
- Definition Classes
- Parsing
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
object
Conflict
Contains the description of the various LL(1) conflicts.
Contains the description of the various LL(1) conflicts.
- Definition Classes
- Parsing
-
object
Parser
Factory of LL(1) parsers.
Factory of LL(1) parsers.
- Definition Classes
- Parsing
-
object
PrettyPrinter
Factory of pretty printers.
Factory of pretty printers.
- Definition Classes
- PrettyPrinting
-
object
Implicits extends UnsafeImplicits
Contains an instance for Uninteresting for every type.
Contains an instance for Uninteresting for every type. The Uninteresting instance for
Unit
is distinct.- Definition Classes
- Syntaxes
-
object
SafeImplicits
Contains the instance for Uninteresting of
Unit
.Contains the instance for Uninteresting of
Unit
.- Definition Classes
- Syntaxes
-
object
Syntax
Contains primitive basic syntaxes and syntax combinators.
Contains primitive basic syntaxes and syntax combinators.
- Definition Classes
- Syntaxes
Inherited from Debug
Inherited from Operators
Inherited from PrettyPrinting
Inherited from Enumeration
Inherited from Parsing
Inherited from Syntaxes
Inherited from AnyRef
Inherited from Any
Abstract Members
Parsing
Syntax
Parse Results
Basic Syntaxes
Combinators
Priority Levels
Priority levels for the operators
combinator.
Associativity
Associativity for priority levels.
Overview
Scallion is a library for easily writing LL(1) parsers in Scala, with support for pretty printing. See the package scallion for more information.