package token
- Alphabetic
- By Inheritance
- token
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- sealed trait Impl extends AnyRef
The Impl trait is used to provide implementation of the parser requirements from
LanguageDefThe Impl trait is used to provide implementation of the parser requirements from
LanguageDef- Since
2.2.0
- case class LanguageDef(commentStart: String, commentEnd: String, commentLine: String, nestedComments: Boolean, identStart: Impl, identLetter: Impl, opStart: Impl, opLetter: Impl, keywords: Set[String], operators: Set[String], caseSensitive: Boolean, space: Impl) extends Product with Serializable
This class is required to construct a TokenParser.
This class is required to construct a TokenParser. It defines the various characteristics of the language to be tokenised. Where a parameter can be either a
Set[Char]or aParsleyobject, prefer theSetwhere possible. It will unlock a variety of faster intrinsic versions of the parsers, which will greatly improve tokenisation performance! In addition, the Sets are one time converted to heavily optimised BitSets, though that has up to 8KB memory usage associated but at least doubles the execution speed for that instruction. Seeparsley.Impl.- commentStart
For multi-line comments; how does the comment start? (If this or
commentEndis the empty string, multi-line comments are disabled)- commentEnd
For multi-line comments; how does the comment end? (If this or
commentEndis the empty string, multi-line comments are disabled)- commentLine
For single-line comments; how does the comment start? (This this is the empty string, single-line comments are disabled)
- nestedComments
Are multi-line comments allowed to be nested inside each other? E.g. If
{-and-}are opening and closing comments, is the following valid syntax:{-{-hello -}-}? Note in C this is not the case.- identStart
What characters can an identifier in the language start with?
- identLetter
What characters can an identifier in the language consist of after the starting character?
- opStart
What characters can an operator in the language start with?
- opLetter
What characters can an operator in the language consist of after the starting character?
- keywords
What keywords does the language contain?
- operators
What operators does the language contain?
- caseSensitive
Is the language case-sensitive. I.e. is IF equivalent to if?
- space
What characters count as whitespace in the language?
- Since
2.2.0
- class Lexer extends AnyRef
When provided with a
LanguageDef, this class will produce a large variety of parsers that can be used for tokenisation of a language.When provided with a
LanguageDef, this class will produce a large variety of parsers that can be used for tokenisation of a language. This includes parsing numbers and strings in their various formats and ensuring that all operations consume whitespace after them (so-called lexeme parsers). These are very useful in parsing programming languages. This class also has a large number of hand-optimised intrinsic parsers to improve performance!- Since
2.2.0
- final case class Parser(p: Parsley[_]) extends Impl with Product with Serializable
The implementation provided is a parser which parses the required token.
The implementation provided is a parser which parses the required token.
- p
The parser which will parse the token
- Since
2.2.0
- final case class Predicate(f: (Char) => Boolean) extends Impl with Product with Serializable
The implementation provided is a function which matches on the input streams characters
The implementation provided is a function which matches on the input streams characters
- f
The predicate that input tokens are tested against
- Since
2.2.0
Value Members
- object CharSet
This implementation uses a set of valid tokens.
This implementation uses a set of valid tokens. It is converted to a high-performance BitSet.
- Since
2.2.0
- object LanguageDef extends Serializable
This object contains any preconfigured language definitions
This object contains any preconfigured language definitions
- Since
2.2.0
- case object NotRequired extends Impl with Product with Serializable
This implementation states that the required functionality is not required.
This implementation states that the required functionality is not required. If it is used it will raise an error at parse-time
- Since
2.2.0
Deprecated Value Members
- object BitGen
This implementation uses a predicate to generate a BitSet.
This implementation uses a predicate to generate a BitSet. This should be preferred over
Predicatewhen the function in question is expensive to execute and the parser itself is expected to be used many times. If the predicate is cheap, this is unlikely to provide any performance improvements, but will instead incur heavy space costs- Annotations
- @deprecated
- Deprecated
(Since version 2.8.4) This will be removed in Parsley 3.0, use Predicate 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.