object registers
This module contains all the functionality and operations for using and manipulating registers.
- Since
2.2.0
- Alphabetic
- By Inheritance
- registers
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
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].- Since
2.2.0
- 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.
- implicit final class RegisterMethods[P, A] extends AnyRef
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(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- 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()
- 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(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- object Reg
Deprecated Value Members
- 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
rof typeS
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.get instead
- Since
2.2.0
- 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
rapplied toffrompf
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.gets(pf) instead
- Since
2.2.0
- Note
The value is fetched after
pfis 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
rapplied tof
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.gets(f) instead
- Since
2.2.0
- def local[R, A](r: Reg[R], f: (R) => R, p: => Parsley[A]): Parsley[A]
For the duration of parser
pthe state stored in registerris instead modified withf.For the duration of parser
pthe state stored in registerris instead modified withf. The change is undone afterphas 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
pwith the modified state
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.local(f)(p) instead
- Since
2.2.0
- 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
qthe state stored in registerris instead set to the return value ofp.For the duration of parser
qthe state stored in registerris instead set to the return value ofp. The change is undone afterqhas 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
qwith the modified state
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.local(p)(q) instead
- Since
2.2.0
- def local[R, A](r: Reg[R], x: R, p: => Parsley[A]): Parsley[A]
For the duration of parser
pthe state stored in registerris instead set tox.For the duration of parser
pthe state stored in registerris instead set tox. The change is undone afterphas 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
pwith the modified state
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.local(x)(p) instead
- Since
2.2.0
- def modify[S](r: Reg[S], f: (S) => S): Parsley[Unit]
Modifies the value contained in register
rusing functionf.Modifies the value contained in register
rusing 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
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.modify(f) instead
- Since
2.2.0
- def put[S](r: Reg[S], p: => Parsley[S]): Parsley[Unit]
Places the result of running
pinto registerr.Places the result of running
pinto registerr.- r
The index of the register to place the value in
- p
The parser to derive the value from
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.put(p) instead
- Since
2.2.0
- def put[S](r: Reg[S], x: S): Parsley[Unit]
Consumes no input and places the value
xinto registerr.Consumes no input and places the value
xinto registerr.- r
The index of the register to place the value in
- x
The value to place in the register
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.put(x) instead
- Since
2.2.0
- def puts[A, S](r: Reg[S], p: => Parsley[A], f: (A) => S): Parsley[Unit]
Places the result of running
pinto registerr.Places the result of running
pinto registerr.- r
The index of the register to place the value in
- p
The parser to derive the value from
- f
A function which adapts the result of
pso that it can fit inr
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use r.puts(p, f) instead
- Since
3.0.0
- 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 registerregwill be reverted.rollback(reg, p)will performp, but if it fails without consuming input, any changes to the registerregwill 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
- Annotations
- @deprecated
- Deprecated
(Since version 3.2.0) This combinator will be removed in 4.0.0, use reg.rollback(p) instead
- Since
2.2.0
This is the documentation for Parsley.
Package structure
The parsley package contains the
Parsleyclass, as well as theResult,Success, andFailuretypes. 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.Parsleycontains the bulk of the core "function-style" combinators, as well as the implicit classes which enable the "method-style" combinators.parsley.combinatorcontains many helpful combinators that simplify some common parser patterns.parsley.charactercontains the combinators needed to read characters and strings, as well as combinators to match specific sub-sets of characters.parsley.debugcontains debugging combinators, helpful for identifying faults in parsers.parsley.iocontains extension methods to run parsers with input sourced from IO sources.parsley.exprcontains the following sub modules:parsley.expr.chaincontains combinators used in expression parsingparsley.expr.precedenceis a builder for expression parsers built on a precedence table.parsley.implicitscontains several implicits to add syntactic sugar to the combinators. These are sub-categorised into the following sub modules:parsley.implicits.charactercontains implicits to allow you to use character and string literals as parsers.parsley.implicits.combinatorcontains implicits related to combinators, such as the ability to make any parser into aParsley[Unit]automatically.parsley.implicits.liftenables postfix application of the lift combinator onto a function (or value).parsley.implicits.zippedenables boths a reversed form of lift where the function appears on the right and is applied on a tuple (useful when type inference has failed) as well as a.zippedmethod for building tuples out of several combinators.parsley.errorscontains modules to deal with error messages, their refinement and generation.parsley.errors.combinatorprovides combinators that can be used to either produce more detailed errors as well as refine existing errors.parsley.liftcontains 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.registerscontains combinators that interact with the context-sensitive functionality in the form of registers.parsley.tokencontains theLexerclass that provides a host of helpful lexing combinators when provided with the description of a language.parsley.unsafecontains unsafe (and not thread-safe) ways of speeding up the execution of a parser.