object registers
This module contains all the functionality and operations for using and manipulating registers.
- Alphabetic
- By Inheritance
- registers
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
class
Reg[A] extends AnyRef
This class is used to index registers within the mutable state.
This class is used to index registers within the mutable state. Currently, there are only 4 available registers, so use them wisely!
If you need more than four registers but know that they will be used at different times you can rename your register, as long as they point to the same reference. You may find the Parsley[A].cast[B: ClassTag]: Parsley[B] combinator useful to change the type of a
Reg[Any]
.- Note
It is undefined behaviour to use a register in multiple different independent parsers. You should be careful to parameterise the registers in shared parsers and allocate fresh ones for each "top-level" parser you will run.
Value Members
-
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
get[S](r: Reg[S]): Parsley[S]
Consumes no input and returns the value stored in one of the parser registers.
Consumes no input and returns the value stored in one of the parser registers.
- S
The type of the value in register
r
(this will result in a runtime type-check)- r
The index of the register to collect from
- returns
The value stored in register
r
of typeS
- Note
There are only 4 registers at present.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
gets[S, A](r: Reg[S], pf: Parsley[(S) ⇒ A]): Parsley[A]
Returns the value stored in one of the parser registers after applying a function obtained from given parser.
Returns the value stored in one of the parser registers after applying a function obtained from given parser.
- S
The type of the value in register
r
(this will result in a runtime type-check)- A
The desired result type
- r
The index of the register to collect from
- pf
The parser which provides the function to transform values
- returns
The value stored in register
r
applied tof
frompf
- Note
There are only 4 registers at present. The value is fetched after
pf
is executed
-
def
gets[S, A](r: Reg[S], f: (S) ⇒ A): Parsley[A]
Consumes no input and returns the value stored in one of the parser registers after applying a function.
Consumes no input and returns the value stored in one of the parser registers after applying a function.
- S
The type of the value in register
r
(this will result in a runtime type-check)- A
The desired result type
- r
The index of the register to collect from
- f
The function used to transform the value in the register
- returns
The value stored in register
r
applied tof
- Note
There are only 4 registers at present.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
local[R, A](r: Reg[R], f: (R) ⇒ R, p: ⇒ Parsley[A]): Parsley[A]
For the duration of parser
p
the state stored in registerr
is instead modified withf
.For the duration of parser
p
the state stored in registerr
is instead modified withf
. The change is undone afterp
has finished.- r
The index of the register to modify
- f
The function used to modify the value in register
r
- p
The parser to execute with the adjusted state
- returns
The parser that performs
p
with the modified state
- Note
There are only 4 registers at present.
-
def
local[R, A](r: Reg[R], p: ⇒ Parsley[R], q: ⇒ Parsley[A]): Parsley[A]
For the duration of parser
q
the state stored in registerr
is instead set to the return value ofp
.For the duration of parser
q
the state stored in registerr
is instead set to the return value ofp
. The change is undone afterq
has finished.- r
The index of the register to modify
- p
The parser whose return value is placed in register
r
- q
The parser to execute with the adjusted state
- returns
The parser that performs
q
with the modified state
- Note
There are only 4 registers at present.
-
def
local[R, A](r: Reg[R], x: R, p: ⇒ Parsley[A]): Parsley[A]
For the duration of parser
p
the state stored in registerr
is instead set tox
.For the duration of parser
p
the state stored in registerr
is instead set tox
. The change is undone afterp
has finished.- r
The index of the register to modify
- x
The value to place in the register
r
- p
The parser to execute with the adjusted state
- returns
The parser that performs
p
with the modified state
- Note
There are only 4 registers at present.
-
def
modify[S](r: Reg[S], f: (S) ⇒ S): Parsley[Unit]
Modifies the value contained in register
r
using functionf
.Modifies the value contained in register
r
using functionf
.- S
The type of value currently assumed to be in the register
- r
The index of the register to modify
- f
The function used to modify the register
- Note
There are only 4 registers at present.
-
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
put[S](r: Reg[S], p: ⇒ Parsley[S]): Parsley[Unit]
Places the result of running
p
into registerr
.Places the result of running
p
into registerr
.- r
The index of the register to place the value in
- p
The parser to derive the value from
- Note
There are only 4 registers at present.
-
def
put[S](r: Reg[S], x: S): Parsley[Unit]
Consumes no input and places the value
x
into registerr
.Consumes no input and places the value
x
into registerr
.- r
The index of the register to place the value in
- x
The value to place in the register
- Note
There are only 4 registers at present.
-
def
rollback[A, B](reg: Reg[A], p: Parsley[B]): Parsley[B]
rollback(reg, p)
will performp
, but if it fails without consuming input, any changes to the registerreg
will be reverted.rollback(reg, p)
will performp
, but if it fails without consuming input, any changes to the registerreg
will be reverted.- reg
The register to rollback on failure of
p
- p
The parser to perform
- returns
The result of the parser
p
, if any
- Since
2.0
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
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
- @throws( ... ) @native()
- object Reg
This is the documentation for Parsley.
Package structure
The parsley package contains the
Parsley
class, as well as theResult
,Success
, andFailure
types. In addition to these, it also contains the following packages and "modules" (a module is defined as being an object which mocks a package):parsley.Parsley
contains the bulk of the core "function-style" combinators, as well as the implicit classes which enable the "method-style" combinators.parsley.combinator
contains many helpful combinators that simplify some common parser patterns.parsley.character
contains the combinators needed to read characters and strings, as well as combinators to match specific sub-sets of characters.parsley.debug
contains debugging combinators, helpful for identifying faults in parsers.parsley.expr
contains the following sub modules:parsley.expr.chain
contains combinators used in expression parsingparsley.expr.precedence
is a builder for expression parsers built on a precedence table.parsley.implicits
contains several implicits to add syntactic sugar to the combinators, such as being able to use character and string literals directly as parsers, as well as enabling lifting of functions to work on parsers.parsley.lift
contains functions which lift functions that work on regular types to those which now combine the results of parsers returning those same types. these are ubiquitous.parsley.registers
contains combinators that interact with the context-sensitive functionality in the form of registers.parsley.token
contains theLexer
class that provides a host of helpful lexing combinators when provided with the description of a language.parsley.unsafe
contains unsafe (and not thread-safe) ways of speeding up the execution of a parser.In addition to the modules and packages outlined above, this version of Parsley (up to version 3.0), also includes the so-called
old-style
API, which is deprecated (see the Parsley wiki for a discussion of these differences). You should use the modules described above, and avoid the following:parsley.BitGen
parsley.Char
parsley.CharSet
parsley.Combinator
parsley.ExpressionParser
parsley.Impl
parsley.Implicits
parsley.LanguageDef
parsley.NotRequired
parsley.Parser
parsley.Predicate
parsley.Reg
parsley.TokenParser