progs/lexer/lex.sc
changeset 844 bbbc2a7940cb
parent 827 67c8a6e6a305
child 846 3a535de22816
equal deleted inserted replaced
843:97b622202547 844:bbbc2a7940cb
   126   case (ALT(r1, r2), Right(v2)) => Right(inj(r2, c, v2))
   126   case (ALT(r1, r2), Right(v2)) => Right(inj(r2, c, v2))
   127   case (CHAR(d), Empty) => Chr(c) 
   127   case (CHAR(d), Empty) => Chr(c) 
   128   case (RECD(x, r1), _) => Rec(x, inj(r1, c, v))
   128   case (RECD(x, r1), _) => Rec(x, inj(r1, c, v))
   129 }
   129 }
   130 
   130 
   131 // lexing functions including simplification
   131 // lexing functions without simplification
   132 def lex(r: Rexp, s: List[Char]) : Val = s match {
   132 def lex(r: Rexp, s: List[Char]) : Val = s match {
   133   case Nil => if (nullable(r)) mkeps(r) else 
   133   case Nil => if (nullable(r)) mkeps(r) else 
   134     { throw new Exception("lexing error") } 
   134     { throw new Exception("lexing error") } 
   135   case c::cs => inj(r, c, lex(der(c, r), cs))
   135   case c::cs => inj(r, c, lex(der(c, r), cs))
   136 }
   136 }