90 case T_NUM(n)::ts => Set((n, ts)) |
90 case T_NUM(n)::ts => Set((n, ts)) |
91 case _ => Set () |
91 case _ => Set () |
92 } |
92 } |
93 } |
93 } |
94 |
94 |
95 case object FNumParser extends Parser[List[Token], Float] { |
95 case object FNumParser extends Parser[List[Token], Double] { |
96 def parse(ts: List[Token]) = ts match { |
96 def parse(ts: List[Token]) = ts match { |
97 case T_FNUM(x)::ts => Set((x, ts)) |
97 case T_FNUM(x)::ts => Set((x, ts)) |
98 case _ => Set() |
98 case _ => Set() |
99 } |
99 } |
100 } |
100 } |
127 abstract class Decl |
127 abstract class Decl |
128 |
128 |
129 case class Def(name: String, args: List[(String, String)], ty: String, body: Exp) extends Decl |
129 case class Def(name: String, args: List[(String, String)], ty: String, body: Exp) extends Decl |
130 case class Main(e: Exp) extends Decl |
130 case class Main(e: Exp) extends Decl |
131 case class Const(name: String, v: Int) extends Decl |
131 case class Const(name: String, v: Int) extends Decl |
132 case class FConst(name: String, x: Float) extends Decl |
132 case class FConst(name: String, x: Double) extends Decl |
133 |
133 |
134 case class Call(name: String, args: List[Exp]) extends Exp |
134 case class Call(name: String, args: List[Exp]) extends Exp |
135 case class If(a: BExp, e1: Exp, e2: Exp) extends Exp |
135 case class If(a: BExp, e1: Exp, e2: Exp) extends Exp |
136 case class Var(s: String) extends Exp |
136 case class Var(s: String) extends Exp |
137 case class Num(i: Int) extends Exp // integer numbers |
137 case class Num(i: Int) extends Exp // integer numbers |
138 case class FNum(i: Float) extends Exp // floating numbers |
138 case class FNum(i: Double) extends Exp // floating numbers |
139 case class ChConst(c: Int) extends Exp // char constant |
139 case class ChConst(c: Int) extends Exp // char constant |
140 case class Aop(o: String, a1: Exp, a2: Exp) extends Exp |
140 case class Aop(o: String, a1: Exp, a2: Exp) extends Exp |
141 case class Sequence(e1: Exp, e2: Exp) extends Exp |
141 case class Sequence(e1: Exp, e2: Exp) extends Exp |
142 case class Bop(o: String, a1: Exp, a2: Exp) extends BExp |
142 case class Bop(o: String, a1: Exp, a2: Exp) extends BExp |
143 |
143 |