progs/lexer/lexer.sc
changeset 800 9eea6a801e10
parent 793 46cc69622a56
child 826 b0352633bf48
equal deleted inserted replaced
799:85267be9a5ed 800:9eea6a801e10
   197   case c::Nil => CHAR(c)
   197   case c::Nil => CHAR(c)
   198   case c::s => ALT(CHAR(c), Range(s))
   198   case c::s => ALT(CHAR(c), Range(s))
   199 }
   199 }
   200 def RANGE(s: String) = Range(s.toList)
   200 def RANGE(s: String) = Range(s.toList)
   201 
   201 
   202 val SYM = RANGE("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz_")
   202 val SYM = RANGE("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_")
   203 val DIGIT = RANGE("0123456789")
   203 val DIGIT = RANGE("0123456789")
   204 val ID = SYM ~ (SYM | DIGIT).% 
   204 val ID = SYM ~ (SYM | DIGIT).% 
   205 val NUM = PLUS(DIGIT)
   205 val NUM = PLUS(DIGIT)
   206 val KEYWORD : Rexp = "skip" | "while" | "do" | "if" | "then" | "else" | "read" | "write" 
   206 val KEYWORD : Rexp = "skip" | "while" | "do" | "if" | "then" | "else" | "read" | "write" 
   207 val SEMI: Rexp = ";"
   207 val SEMI: Rexp = ";"