updated to Doubles trhoughout
authorChristian Urban <christian.urban@kcl.ac.uk>
Thu, 20 Jan 2022 08:58:38 +0000
changeset 868 8fb3b6d3be70
parent 867 54bcd848d716
child 869 81ee93b87258
updated to Doubles trhoughout
cws/cw05.pdf
cws/cw05.tex
solution/cw5/fun_llvm.sc
solution/cw5/fun_parser.sc
solution/cw5/fun_tokens.sc
Binary file cws/cw05.pdf has changed
--- a/cws/cw05.tex	Mon Jan 10 23:52:51 2022 +0000
+++ b/cws/cw05.tex	Thu Jan 20 08:58:38 2022 +0000
@@ -108,13 +108,13 @@
                ty: String, body: Exp) extends Decl
 case class Main(e: Exp) extends Decl
 case class Const(name: String, v: Int) extends Decl
-case class FConst(name: String, x: Float) extends Decl
+case class FConst(name: String, x: Double) extends Decl
 
 case class Call(name: String, args: List[Exp]) extends Exp
 case class If(a: BExp, e1: Exp, e2: Exp) extends Exp
 case class Var(s: String) extends Exp
 case class Num(i: Int) extends Exp     // integer numbers
-case class FNum(i: Float) extends Exp  // floating numbers
+case class FNum(i: Double) extends Exp  // floating numbers
 case class ChConst(c: Int) extends Exp // char constants
 case class Aop(o: String, a1: Exp, a2: Exp) extends Exp
 case class Sequence(e1: Exp, e2: Exp) extends Exp
--- a/solution/cw5/fun_llvm.sc	Mon Jan 10 23:52:51 2022 +0000
+++ b/solution/cw5/fun_llvm.sc	Thu Jan 20 08:58:38 2022 +0000
@@ -63,7 +63,7 @@
 case class KVar(s: String, ty: Ty = "UNDEF") extends KVal
 case class KLoad(v: KVal) extends KVal
 case class KNum(i: Int) extends KVal
-case class KFNum(i: Float) extends KVal
+case class KFNum(i: Double) extends KVal
 case class KChr(c: Int) extends KVal
 case class Kop(o: String, v1: KVal, v2: KVal, ty: Ty = "UNDEF") extends KVal
 case class KCall(o: String, vrs: List[KVal], ty: Ty = "UNDEF") extends KVal
--- a/solution/cw5/fun_parser.sc	Mon Jan 10 23:52:51 2022 +0000
+++ b/solution/cw5/fun_parser.sc	Thu Jan 20 08:58:38 2022 +0000
@@ -92,7 +92,7 @@
   }
 }
 
-case object FNumParser extends Parser[List[Token], Float] {
+case object FNumParser extends Parser[List[Token], Double] {
   def parse(ts: List[Token]) = ts match {
     case T_FNUM(x)::ts => Set((x, ts)) 
     case _ => Set()
@@ -129,13 +129,13 @@
 case class Def(name: String, args: List[(String, String)], ty: String, body: Exp) extends Decl
 case class Main(e: Exp) extends Decl
 case class Const(name: String, v: Int) extends Decl
-case class FConst(name: String, x: Float) extends Decl
+case class FConst(name: String, x: Double) extends Decl
 
 case class Call(name: String, args: List[Exp]) extends Exp
 case class If(a: BExp, e1: Exp, e2: Exp) extends Exp
 case class Var(s: String) extends Exp
 case class Num(i: Int) extends Exp     // integer numbers
-case class FNum(i: Float) extends Exp  // floating numbers
+case class FNum(i: Double) extends Exp  // floating numbers
 case class ChConst(c: Int) extends Exp // char constant
 case class Aop(o: String, a1: Exp, a2: Exp) extends Exp
 case class Sequence(e1: Exp, e2: Exp) extends Exp
--- a/solution/cw5/fun_tokens.sc	Mon Jan 10 23:52:51 2022 +0000
+++ b/solution/cw5/fun_tokens.sc	Thu Jan 20 08:58:38 2022 +0000
@@ -244,7 +244,7 @@
 case class T_FID(s: String) extends Token
 case class T_OP(s: String) extends Token
 case class T_NUM(n: Int) extends Token
-case class T_FNUM(x: Float) extends Token
+case class T_FNUM(x: Double) extends Token
 case class T_KWD(s: String) extends Token
 case class T_TY(s: String) extends Token
 case class T_CHR(i: Int) extends Token
@@ -256,7 +256,7 @@
   case ("o", s) => T_OP(s)
   case ("n", s) => T_NUM(s.toInt)
   case ("ch", s) => if (s == "'\\n'") T_CHR(10) else T_CHR(s(1).toInt)
-  case ("f", s) => T_FNUM(s.toFloat) 
+  case ("f", s) => T_FNUM(s.toDouble) 
   case ("s", _) => T_SEMI
   case ("c", _) => T_COMMA
   case ("co", _) => T_COLON