separators

parsley.token.cats$.LexerNonEmpty.cats$.lexeme$.separators$
object separators

Attributes

Source
cats.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
separators.type

Members list

Value members

Concrete methods

def commaSep1[A](p: Parsley[A]): Parsley[NonEmptyList[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 NonEmptyList(x1, .., xn). If p fails having consumed input, the whole parser fails. Requires at least one p to have been parsed.

Value parameters

p

the parser whose results are collected into a list.

Attributes

Returns

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

Since

1.3.0

Example

scala> ...
scala> val stmts = lexer.lexeme.separators.commaSep1(int)
scala> stmts.parse("7, 3,2")
val res0 = Success(NonEmptyList(7, 3, 2))
scala> stmts.parse("")
val res1 = Failure(..)
scala> stmts.parse("1")
val res2 = Success(NonEmptyList(1))
scala> stmts.parse("1, 2, ")
val res3 = Failure(..) // no trailing comma allowed
Source
cats.scala
def semiSep1[A](p: Parsley[A]): Parsley[NonEmptyList[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 NonEmptyList(x1, .., xn). If p fails having consumed input, the whole parser fails. Requires at least one p to have been parsed.

Value parameters

p

the parser whose results are collected into a list.

Attributes

Returns

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

Since

1.3.0

Example

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