fixed Ticket #212

at the same time, made it easier to customise the shape of identifiers

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@13362 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
moors 2007-11-27 19:05:35 +00:00
parent 54eaf3c0a3
commit 9dc83d1e52
1 changed files with 8 additions and 1 deletions

View File

@ -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)