diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2007-11-27 19:05:35 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2007-11-27 19:05:35 +0000 |
commit | 1999c1bdc33f117b695d10c6eb77c82f60e2fbe2 (patch) | |
tree | b864a9d1112ecf36f3d5aca4727f6f2c2edbb8bf /src/library | |
parent | 08a4772207c5500cc93b3cdedff8bfb2f4322a66 (diff) | |
download | scala-1999c1bdc33f117b695d10c6eb77c82f60e2fbe2.tar.gz scala-1999c1bdc33f117b695d10c6eb77c82f60e2fbe2.tar.bz2 scala-1999c1bdc33f117b695d10c6eb77c82f60e2fbe2.zip |
fixed Ticket #212
at the same time, made it easier to customise the shape of identifiers
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/util/parsing/combinator/lexical/StdLexical.scala | 9 |
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) |