solutions/cw3/parser.sc
changeset 974 0cb4bf2469d1
parent 961 c0600f8b6427
equal deleted inserted replaced
973:f25d338d16c9 974:0cb4bf2469d1
   131     def parse(tsb: List[Token]) = tsb match {
   131     def parse(tsb: List[Token]) = tsb match {
   132         case T_STRING(s) :: rest => Set((s, rest))
   132         case T_STRING(s) :: rest => Set((s, rest))
   133         case _ => Set()
   133         case _ => Set()
   134     }
   134     }
   135 }
   135 }
       
   136 
   136 
   137 
   137 
   138 
   138 // WHILE Language Parsing
   139 // WHILE Language Parsing
   139 lazy val AExp: Parser[List[Token], AExp] =
   140 lazy val AExp: Parser[List[Token], AExp] =
   140   (Te ~ T_OP("+") ~ AExp).map{ case x ~ _ ~ z => Aop("+", x, z): AExp } ||
   141   (Te ~ T_OP("+") ~ AExp).map{ case x ~ _ ~ z => Aop("+", x, z): AExp } ||