enclosing
This object contains helper combinators for parsing terms enclosed by common symbols.
Attributes
- Since:
4.0.0
- Source:
- Lexer.scala
- Graph
- Supertypes
- Self type
- enclosing.type
Members list
Value members
Concrete methods
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 ofp
.- 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
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 ofp
.- 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
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 ofp
.- 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
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 ofp
.- 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