-
Notifications
You must be signed in to change notification settings - Fork 14
/
character.scala
37 lines (35 loc) · 1.36 KB
/
character.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* SPDX-FileCopyrightText: © 2021 Parsley Contributors <https://github.com/j-mie6/Parsley/graphs/contributors>
* SPDX-License-Identifier: BSD-3-Clause
*/
package parsley.implicits
import parsley.Parsley
import parsley.character.{char, string}
/** Provides implicit conversions for characters and strings into parsers.
*
* The use of `char` and `string` can be distracting to the overall structure
* of the parser with respect to the grammar. This module exposes combinators
* that can implicitly convert Scala's string and character literals so that
* they represent parsers. These will not be whitespace sensitive.
*
* @since 3.0.0
*/
object character {
// $COVERAGE-OFF$
/** Converts a string literal into a parser that reads that string.
*
* Allows for the implicit application of the `string` combinator to a
* string literal.
*
* @see [[parsley.character.string `character.string`]]
*/
@inline implicit def stringLift(str: String): Parsley[String] = string(str)
/** Converts a character literal into a parser that reads that character.
*
* Allows for the implicit application of the `char` combinator to a
* character literal.
*
* @see [[parsley.character.char `character.char`]]
*/
@inline implicit def charLift(c: Char): Parsley[Char] = char(c)
// $COVERAGE-ON$
}