blob: edd4f286ca672e8f5bd0d1c52224373c5d19c0f6 (
plain) (
blame)
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
38
39
40
41
42
43
44
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.util.parsing.combinator.syntactical
import scala.util.parsing.syntax._
/** This component provides primitive parsers for the standard tokens defined in `StdTokens'.
*
* @author Martin Odersky, Adriaan Moors
*/
trait StdTokenParsers extends TokenParsers {
type Tokens <: StdTokens
import lexical.{Keyword, NumericLit, StringLit, Identifier}
/** A parser which matches a single keyword token.
*
* @param chars The character string making up the matched keyword.
* @return a `Parser' that matches the given string
*/
implicit def keyword(chars: String): Parser[String] = accept(Keyword(chars)) ^^ (_.chars)
/** A parser which matches a numeric literal */
def numericLit: Parser[String] =
elem("number", _.isInstanceOf[NumericLit]) ^^ (_.chars)
/** A parser which matches a string literal */
def stringLit: Parser[String] =
elem("string literal", _.isInstanceOf[StringLit]) ^^ (_.chars)
/** A parser which matches an identifier */
def ident: Parser[String] =
elem("identifier", _.isInstanceOf[Identifier]) ^^ (_.chars)
}
|