separators

parsley.token.Lexer.lexeme$.separators$
object separators

This object contains helper combinators for parsing terms separated by common symbols.

Attributes

Since:

4.0.0

Source:
Lexer.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Value members

Concrete methods

def commaSep[A](p: Parsley[A]): Parsley[List[A]]

This combinator parses zero or more occurrences of p, separated by commas.

This combinator parses zero or more occurrences of p, separated by commas.

Behaves just like commaSep1, except does not require an initial p, returning the empty list instead.

Attributes

p

the parser whose results are collected into a list.

Returns:

a parser that parses p delimited by commas, returning the list of p's results.

Since:

4.0.0

Example:

scala> ...
scala> val stmts = lexer.lexeme.separators.commaSep(int)
scala> stmts.parse("7, 3,2")
val res0 = Success(List(7, 3, 2))
scala> stmts.parse("")
val res1 = Success(Nil)
scala> stmts.parse("1")
val res2 = Success(List(1))
scala> stmts.parse("1, 2, ")
val res3 = Failure(..) // no trailing comma allowed
Source:
Lexer.scala
def commaSep1[A](p: Parsley[A]): Parsley[List[A]]

This combinator parses one or more occurrences of p, separated by commas.

This combinator parses one or more occurrences of p, separated by commas.

First parses a p. Then parses a comma followed by p until there are no more commas. The results of the p's, x1 through xn, are returned as List(x1, .., xn). If p fails having consumed input, the whole parser fails. Requires at least one p to have been parsed.

Attributes

p

the parser whose results are collected into a list.

Returns:

a parser that parses p delimited by commas, returning the list of p's results.

Since:

4.0.0

Example:

scala> ...
scala> val stmts = lexer.lexeme.separators.commaSep1(int)
scala> stmts.parse("7, 3,2")
val res0 = Success(List(7, 3, 2))
scala> stmts.parse("")
val res1 = Failure(..)
scala> stmts.parse("1")
val res2 = Success(List(1))
scala> stmts.parse("1, 2, ")
val res3 = Failure(..) // no trailing comma allowed
Source:
Lexer.scala
def semiSep[A](p: Parsley[A]): Parsley[List[A]]

This combinator parses zero or more occurrences of p, separated by semi-colons.

This combinator parses zero or more occurrences of p, separated by semi-colons.

Behaves just like semiSep1, except does not require an initial p, returning the empty list instead.

Attributes

p

the parser whose results are collected into a list.

Returns:

a parser that parses p delimited by semi-colons, returning the list of p's results.

Since:

4.0.0

Example:

scala> ...
scala> val stmts = lexer.lexeme.separators.semiSep(int)
scala> stmts.parse("7; 3;2")
val res0 = Success(List(7; 3; 2))
scala> stmts.parse("")
val res1 = Success(Nil)
scala> stmts.parse("1")
val res2 = Success(List(1))
scala> stmts.parse("1; 2; ")
val res3 = Failure(..) // no trailing semi-colon allowed
Source:
Lexer.scala
def semiSep1[A](p: Parsley[A]): Parsley[List[A]]

This combinator parses one or more occurrences of p, separated by semi-colons.

This combinator parses one or more occurrences of p, separated by semi-colons.

First parses a p. Then parses a semi-colon followed by p until there are no more semi-colons. The results of the p's, x1 through xn, are returned as List(x1, .., xn). If p fails having consumed input, the whole parser fails. Requires at least one p to have been parsed.

Attributes

p

the parser whose results are collected into a list.

Returns:

a parser that parses p delimited by semi-colons, returning the list of p's results.

Since:

4.0.0

Example:

scala> ...
scala> val stmts = lexer.lexeme.separators.semiSep1(int)
scala> stmts.parse("7; 3;2")
val res0 = Success(List(7; 3; 2))
scala> stmts.parse("")
val res1 = Failure(..)
scala> stmts.parse("1")
val res2 = Success(List(1))
scala> stmts.parse("1; 2; ")
val res3 = Failure(..) // no trailing semi-colon allowed
Source:
Lexer.scala