enclosing

parsley.token.Lexer.lexeme$.enclosing$
object enclosing

This object contains helper combinators for parsing terms enclosed 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 angles[A](p: => Parsley[A]): Parsley[A]

This combinator parses a p enclosed within angle brackets.

This combinator parses a p enclosed within angle brackets.

First parse an open bracket, any whitespace, then parse, p, producing x. Finally, parse a closing bracket and any whitespace. If all three parts succeeded, then return x. If any of them failed, this combinator fails.

Attributes

p

the parser to parse between parentheses.

Returns:

a parser that reads an open bracket, then p, then a closing bracket and returns the result of p.

Since:

4.0.0

Example:

scala> ...
scala> val p = lexer.nonlexeme.enclosing.brackets(int)
scala> p.parse("< 5>")
val res0 = Success(5)
scala> p.parse("<5")
val res1 = Failure(...)
scala> p.parse("5>")
val res2 = Failure(...)
Source:
Lexer.scala
def braces[A](p: => Parsley[A]): Parsley[A]

This combinator parses a p enclosed within braces.

This combinator parses a p enclosed within braces.

First parse an open brace, any whitespace, then parse, p, producing x. Finally, parse a closing brace and any whitespace. If all three parts succeeded, then return x. If any of them failed, this combinator fails.

Attributes

p

the parser to parse between parentheses.

Returns:

a parser that reads an open brace, then p, then a closing brace and returns the result of p.

Since:

4.0.0

Example:

scala> ...
scala> val p = lexer.nonlexeme.enclosing.braces(int)
scala> p.parse("{ 5}")
val res0 = Success(5)
scala> p.parse("{5")
val res1 = Failure(...)
scala> p.parse("5}")
val res2 = Failure(...)
Source:
Lexer.scala
def brackets[A](p: => Parsley[A]): Parsley[A]

This combinator parses a p enclosed within square brackets.

This combinator parses a p enclosed within square brackets.

First parse an open bracket, any whitespace, then parse, p, producing x. Finally, parse a closing bracket and any whitespace. If all three parts succeeded, then return x. If any of them failed, this combinator fails.

Attributes

p

the parser to parse between parentheses.

Returns:

a parser that reads an open bracket, then p, then a closing bracket and returns the result of p.

Since:

4.0.0

Example:

scala> ...
scala> val p = lexer.nonlexeme.enclosing.brackets(int)
scala> p.parse("[ 5]")
val res0 = Success(5)
scala> p.parse("[5")
val res1 = Failure(...)
scala> p.parse("5]")
val res2 = Failure(...)
Source:
Lexer.scala
def parens[A](p: => Parsley[A]): Parsley[A]

This combinator parses a p enclosed within parentheses.

This combinator parses a p enclosed within parentheses.

First parse an open parenthesis, any whitespace, then parse, p, producing x. Finally, parse a closing parenthesis and any whitespace. If all three parts succeeded, then return x. If any of them failed, this combinator fails.

Attributes

p

the parser to parse between parentheses.

Returns:

a parser that reads an open parenthesis, then p, then a closing parenthesis and returns the result of p.

Since:

4.0.0

Example:

scala> ...
scala> val p = lexer.nonlexeme.enclosing.parens(int)
scala> p.parse("( 5)")
val res0 = Success(5)
scala> p.parse("(5")
val res1 = Failure(...)
scala> p.parse("5)")
val res2 = Failure(...)
Source:
Lexer.scala