summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/util/parsing/combinator/lexical/StdLexical.scala9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
index b423b04fe4..fd406e6b37 100644
--- a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
+++ b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
@@ -33,9 +33,16 @@ import collection.mutable.HashSet
* @author Martin Odersky, Iulian Dragos, Adriaan Moors
*/
class StdLexical extends Lexical with StdTokens {
+
+ // override this parser to change the characters allowed at the beginning of an identifier
+ def identBegin: Parser[Char] = ('_' ^^ '_') | letter
+
+ // override this parser to change the characters allowed in an identifier (i.e., after the first character)
+ def identCont: Parser[Char] = ('_' ^^ '_') | letter | digit
+
// see `token' in `Scanners'
def token: Parser[Token] =
- ( letter ~ rep( letter | digit ) ^^ lift2(processIdent)
+ ( identBegin ~ rep( identCont ) ^^ lift2(processIdent)
| digit ~ rep( digit ) ^^ lift2(NumericLit)
| '\'' ~ rep( chrExcept('\'', '\n', EofCh) ) ~ '\'' ^^ lift(StringLit)
| '\"' ~ rep( chrExcept('\"', '\n', EofCh) ) ~ '\"' ^^ lift(StringLit)