trait WhitespaceParser extends ParserUtilities
Support for defining the form of whitespace using a parser, rather than a regular expression. This version is useful particularly in cases where the form of comments requires more power than a regular expression can provide (e.g., for nested comments).
- Source
- ParserUtilities.scala
- Alphabetic
- By Inheritance
- WhitespaceParser
- ParserUtilities
- PackratParsers
- RegexParsers
- Parsers
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
type
Elem = Char
- Definition Classes
- RegexParsers → Parsers
-
case class
Error extends NoSuccess with Product with Serializable
- Definition Classes
- Parsers
-
case class
Failure extends NoSuccess with Product with Serializable
- Definition Classes
- Parsers
-
type
Input = Reader[Elem]
- Definition Classes
- Parsers
-
sealed abstract
class
NoSuccess extends ParseResult[Nothing]
- Definition Classes
- Parsers
-
trait
OnceParser[+T] extends Parser[T]
- Definition Classes
- Parsers
-
abstract
class
PackratParser[+T] extends scala.util.parsing.combinator.PackratParsers.Parser[T]
- Definition Classes
- PackratParsers
-
class
PackratReader[+T] extends Reader[T]
- Definition Classes
- PackratParsers
-
sealed abstract
class
ParseResult[+T] extends AnyRef
- Definition Classes
- Parsers
-
abstract
class
Parser[+T] extends (Input) ⇒ ParseResult[T]
- Definition Classes
- Parsers
-
case class
Success[+T] extends ParseResult[T] with Product with Serializable
- Definition Classes
- Parsers
-
case class
~[+a, +b] extends Product with Serializable
- Definition Classes
- Parsers
Abstract Value Members
-
abstract
val
whitespaceParser: PackratParser[Any]
A parser that recognises whitespace.
A parser that recognises whitespace. Normal whitespace handling is turned off while this parser is applied, since we need to avoid an infinite recursion if the form of whitespace is defined using
literalorregex.- Attributes
- protected
Concrete 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
-
def
OnceParser[T](f: (Input) ⇒ ParseResult[T]): Parser[T] with OnceParser[T]
- Definition Classes
- Parsers
-
def
Parser[T](f: (Input) ⇒ ParseResult[T]): Parser[T]
- Definition Classes
- Parsers
-
def
accept[U](expected: String, f: PartialFunction[Elem, U]): Parser[U]
- Definition Classes
- Parsers
-
def
accept[ES](es: ES)(implicit arg0: (ES) ⇒ List[Elem]): Parser[List[Elem]]
- Definition Classes
- Parsers
-
implicit
def
accept(e: Elem): Parser[Elem]
- Definition Classes
- Parsers
-
def
acceptIf(p: (Elem) ⇒ Boolean)(err: (Elem) ⇒ String): Parser[Elem]
- Definition Classes
- Parsers
-
def
acceptMatch[U](expected: String, f: PartialFunction[Elem, U]): Parser[U]
- Definition Classes
- Parsers
-
def
acceptSeq[ES](es: ES)(implicit arg0: (ES) ⇒ Iterable[Elem]): Parser[List[Elem]]
- Definition Classes
- Parsers
-
def
any: PackratParser[Char]
A parser that matches any element, failing if the end of input is reached.
A parser that matches any element, failing if the end of input is reached.
- Definition Classes
- ParserUtilities
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
chainl1[T, U](first: ⇒ Parser[T], p: ⇒ Parser[U], q: ⇒ Parser[(T, U) ⇒ T]): Parser[T]
- Definition Classes
- Parsers
-
def
chainl1[T](p: ⇒ Parser[T], q: ⇒ Parser[(T, T) ⇒ T]): Parser[T]
- Definition Classes
- Parsers
-
def
chainr1[T, U](p: ⇒ Parser[T], q: ⇒ Parser[(T, U) ⇒ U], combine: (T, U) ⇒ U, first: U): Parser[U]
- Definition Classes
- Parsers
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
commit[T](p: ⇒ Parser[T]): Parser[T]
- Definition Classes
- Parsers
-
implicit
def
constToTupleFunction2[A, B, R](r: (A, B) ⇒ R): (~[A, B]) ⇒ R
Convenience conversion to allow arity two functions to be used directly in tree construction actions.
Convenience conversion to allow arity two functions to be used directly in tree construction actions.
- Definition Classes
- ParserUtilities
-
implicit
def
constToTupleFunction3[A, B, C, R](r: (A, B, C) ⇒ R): (~[~[A, B], C]) ⇒ R
Convenience conversion to allow arity three functions to be used directly in tree construction actions.
Convenience conversion to allow arity three functions to be used directly in tree construction actions.
- Definition Classes
- ParserUtilities
-
implicit
def
constToTupleFunction4[A, B, C, D, R](r: (A, B, C, D) ⇒ R): (~[~[~[A, B], C], D]) ⇒ R
Convenience conversion to allow arity four functions to be used directly in tree construction actions.
Convenience conversion to allow arity four functions to be used directly in tree construction actions.
- Definition Classes
- ParserUtilities
-
implicit
def
constToTupleFunction5[A, B, C, D, E, R](r: (A, B, C, D, E) ⇒ R): (~[~[~[~[A, B], C], D], E]) ⇒ R
Convenience conversion to allow arity five functions to be used directly in tree construction actions.
Convenience conversion to allow arity five functions to be used directly in tree construction actions.
- Definition Classes
- ParserUtilities
-
implicit
def
constToTupleFunction6[A, B, C, D, E, F, R](r: (A, B, C, D, E, F) ⇒ R): (~[~[~[~[~[A, B], C], D], E], F]) ⇒ R
Convenience conversion to allow arity six functions to be used directly in tree construction actions.
Convenience conversion to allow arity six functions to be used directly in tree construction actions.
- Definition Classes
- ParserUtilities
-
lazy val
constrainedInt: PackratParser[Int]
Parse digit strings that are constrained to fit into an
Intvalue.Parse digit strings that are constrained to fit into an
Intvalue. If the digit string is too big, a parse error results.- Definition Classes
- ParserUtilities
-
def
elem(e: Elem): Parser[Elem]
- Definition Classes
- Parsers
-
def
elem(kind: String, p: (Elem) ⇒ Boolean): Parser[Elem]
- Definition Classes
- Parsers
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
err(msg: String): Parser[Nothing]
Return an error after skipping white space.
Return an error after skipping white space.
- Definition Classes
- ParserUtilities → Parsers
-
def
failure(msg: String): Parser[Nothing]
Return a failure after skipping white space.
Return a failure after skipping white space.
- Definition Classes
- ParserUtilities → Parsers
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
guard[T](p: ⇒ Parser[T]): Parser[T]
- Definition Classes
- Parsers
-
def
handleWhiteSpace(in: Input): Int
Version of
handleWhiteSpacethat accepts anInputvalue rather than separate source and offset.Version of
handleWhiteSpacethat accepts anInputvalue rather than separate source and offset. By default, just delegates to thehandleWhiteSpaceofRegexParsers.- Definition Classes
- ParserUtilities
-
def
handleWhiteSpace(source: CharSequence, offset: Int): Int
- Attributes
- protected
- Definition Classes
- RegexParsers
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
keywords(ext: Regex, kws: Seq[String]): Parser[String]
Parser for keywords.
Parser for keywords. The list of string arguments gives the text of the keywords in a language. The regular expression gives the possible extension of the keyword to stop the keyword being seen as an identifier instead. For example, the keyword list might contain
"begin"and"end"and the extension regular expression might be[^a-zA-Z0-9]. Thus,beginfollowed by something other than a letter or digit is a keyword, butbeginfoo8is an identifier. This parser succeeds if any of the keywords is present, provided that it's not immediately followed by something that extends it.- Definition Classes
- ParserUtilities
-
implicit
def
literal(s: String): Parser[String]
A parser that matches a literal string after skipping any whitespace that is parsed by
whitespaceParser.A parser that matches a literal string after skipping any whitespace that is parsed by
whitespaceParser.- Definition Classes
- WhitespaceParser → RegexParsers
-
def
log[T](p: ⇒ Parser[T])(name: String): Parser[T]
- Definition Classes
- Parsers
-
def
memo[T](p: Parser[T]): PackratParser[T]
- Definition Classes
- PackratParsers
-
def
mkList[T]: (~[T, List[T]]) ⇒ List[T]
- Definition Classes
- Parsers
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
not[T](p: ⇒ Parser[T]): Parser[Unit]
- Definition Classes
- Parsers
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
opt[T](p: ⇒ Parser[T]): Parser[Option[T]]
- Definition Classes
- Parsers
-
def
parse[T](p: Parser[T], in: Reader): ParseResult[T]
- Definition Classes
- RegexParsers
-
def
parse[T](p: Parser[T], in: CharSequence): ParseResult[T]
- Definition Classes
- RegexParsers
-
def
parse[T](p: Parser[T], in: Reader[Char]): ParseResult[T]
- Definition Classes
- RegexParsers
-
def
parseAll[T](p: Parser[T], in: CharSequence): ParseResult[T]
- Definition Classes
- RegexParsers
-
def
parseAll[T](p: Parser[T], in: Reader): ParseResult[T]
- Definition Classes
- RegexParsers
-
def
parseAll[T](p: Parser[T], in: Reader[Char]): ParseResult[T]
- Definition Classes
- RegexParsers
-
implicit
def
parseResultToTuple2[A, B](p: Parser[~[A, B]]): PackratParser[(A, B)]
Convenience conversion to lift parsers that return 2-tilde-tuples to parsers that return regular 2-tuples.
Convenience conversion to lift parsers that return 2-tilde-tuples to parsers that return regular 2-tuples.
- Definition Classes
- ParserUtilities
-
implicit
def
parseResultToTuple3[A, B, C](p: Parser[~[~[A, B], C]]): PackratParser[(A, B, C)]
Convenience conversion to lift parsers that return 3-tilde-tuples to parsers that return regular 3-tuples.
Convenience conversion to lift parsers that return 3-tilde-tuples to parsers that return regular 3-tuples.
- Definition Classes
- ParserUtilities
-
implicit
def
parseResultToTuple4[A, B, C, D](p: Parser[~[~[~[A, B], C], D]]): PackratParser[(A, B, C, D)]
Convenience conversion to lift parsers that return 4-tilde-tuples to parsers that return regular 4-tuples.
Convenience conversion to lift parsers that return 4-tilde-tuples to parsers that return regular 4-tuples.
- Definition Classes
- ParserUtilities
-
implicit
def
parseResultToTuple5[A, B, C, D, E](p: Parser[~[~[~[~[A, B], C], D], E]]): PackratParser[(A, B, C, D, E)]
Convenience conversion to lift parsers that return 5-tilde-tuples to parsers that return regular 5-tuples.
Convenience conversion to lift parsers that return 5-tilde-tuples to parsers that return regular 5-tuples.
- Definition Classes
- ParserUtilities
-
implicit
def
parseResultToTuple6[A, B, C, D, E, F](p: Parser[~[~[~[~[~[A, B], C], D], E], F]]): PackratParser[(A, B, C, D, E, F)]
Convenience conversion to lift parsers that return 6-tilde-tuples to parsers that return regular 6-tuples.
Convenience conversion to lift parsers that return 6-tilde-tuples to parsers that return regular 6-tuples.
- Definition Classes
- ParserUtilities
-
def
parseString[T](parser: Parser[T], str: String): Either[T, String]
Use
parserto parse the stringstr.Use
parserto parse the stringstr. If the parse is sucessful and produces the valuet, returnLeft (t). Otherwise, returnRight (msg)wheremsgis the mesage produced by the parser.- Definition Classes
- ParserUtilities
-
def
parseWhitespace(in: Input): ParseResult[Any]
If we are parsing whitespace already, fail if we are the end of the input, otherwise succeed with no progress.
If we are parsing whitespace already, fail if we are the end of the input, otherwise succeed with no progress. If we are not already parsing whitespace, then apply the whitespace parser, swallowing any errors from it unless they occur at the end of the input. In other words, an error not at the end is treated as the absence of whitespace.
- Attributes
- protected
-
implicit
def
parser2packrat[T](p: ⇒ Parser[T]): PackratParser[T]
- Definition Classes
- PackratParsers
-
val
parsingWhitespace: Boolean
Are we currently parsing whitespace?
Are we currently parsing whitespace?
- Attributes
- protected
-
def
phrase[T](p: Parser[T]): PackratParser[T]
- Definition Classes
- PackratParsers → Parsers
-
def
positioned[T <: Positional](p: ⇒ Parser[T]): Parser[T]
As for positioned in
RegexParsers, but usesparseWhitespaceto skip whitespace.As for positioned in
RegexParsers, but usesparseWhitespaceto skip whitespace.- Definition Classes
- WhitespaceParser → RegexParsers → Parsers
-
implicit
def
regex(r: Regex): Parser[String]
A parser that matches a regex string after skipping any whitespace that is parsed by
whitespaceParser.A parser that matches a regex string after skipping any whitespace that is parsed by
whitespaceParser.- Definition Classes
- WhitespaceParser → RegexParsers
-
def
rep[T](p: ⇒ Parser[T]): Parser[List[T]]
- Definition Classes
- Parsers
-
def
rep1[T](first: ⇒ Parser[T], p0: ⇒ Parser[T]): Parser[List[T]]
- Definition Classes
- Parsers
- Annotations
- @migration
- Migration
(Changed in version 2.9.0) The
p0call-by-name arguments is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.
-
def
rep1[T](p: ⇒ Parser[T]): Parser[List[T]]
- Definition Classes
- Parsers
-
def
rep1sep[T](p: ⇒ Parser[T], q: ⇒ Parser[Any]): Parser[List[T]]
- Definition Classes
- Parsers
-
def
repN[T](num: Int, p: ⇒ Parser[T]): Parser[List[T]]
- Definition Classes
- Parsers
-
def
repsep[T](p: ⇒ Parser[T], q: ⇒ Parser[Any]): Parser[List[T]]
- Definition Classes
- Parsers
-
def
result[T](v: ⇒ T): Parser[T]
Construct a parser that always succeeds and returns value
v.Construct a parser that always succeeds and returns value
v. See also thesuccesscombinator in the Scala library that does something similar but always returns the same value each time since the parameter is not passed by name.- Definition Classes
- ParserUtilities
-
def
skipWhitespace: Boolean
- Definition Classes
- WhitespaceParser → RegexParsers
-
def
stringToInt(s: String): Either[Int, String]
Convert the digit string
sto anIntif it's in range, but return an error message if it's too big.Convert the digit string
sto anIntif it's in range, but return an error message if it's too big.- Definition Classes
- ParserUtilities
-
def
success[T](v: T): Parser[T]
- Definition Classes
- Parsers
-
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( ... )
-
val
whiteSpace: Regex
- Attributes
- protected
- Definition Classes
- RegexParsers
-
def
wrap[T, U](p: ⇒ Parser[T], f: (T) ⇒ Either[U, String]): Parser[U]
Wrap a parser
pthat produces a value of typeTto produce a parser returning values of typeU.Wrap a parser
pthat produces a value of typeTto produce a parser returning values of typeU. Whitespace is skipped (if we are skipping white space) beforepis applied, so that we have access to the first non-whitespace position.The function
fis responsible for converting theTvalue into either aUvalue or a string that indicates what went wrong. In the latter case, the resulting parser will error at the original position with the message, ignoring any other errors at that position. Failures or errors ofpwill be lifted to the returned type.- Definition Classes
- ParserUtilities
-
object
NoSuccess
- Definition Classes
- Parsers