summaryrefslogtreecommitdiff
path: root/Source/Core/Parser.cs
diff options
context:
space:
mode:
authorGravatar Dietrich <dgeisler50@gmail.com>2015-04-20 04:17:46 -0600
committerGravatar Dietrich <dgeisler50@gmail.com>2015-04-20 04:17:46 -0600
commit50ea5ab6baf31da6fa3be4f1420d683fd54013cd (patch)
tree5eee85a50aff8d1e6c27eb8f7f95c5b7cd05485d /Source/Core/Parser.cs
parent0776b808b14e62833b3eac1c30c8ac8cc7e62c20 (diff)
Added float type to the Parser and Scanner
Diffstat (limited to 'Source/Core/Parser.cs')
-rw-r--r--Source/Core/Parser.cs24
1 files changed, 22 insertions, 2 deletions
diff --git a/Source/Core/Parser.cs b/Source/Core/Parser.cs
index 696a72ed..5545d8c4 100644
--- a/Source/Core/Parser.cs
+++ b/Source/Core/Parser.cs
@@ -1717,7 +1717,7 @@ out List<Variable>/*!*/ ins, out List<Variable>/*!*/ outs, out QKeyValue kv) {
}
void AtomExpression(out Expr/*!*/ e) {
- Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ x; int n; BigNum bn; BigDec bd;
+ Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ x; int n; BigNum bn; BigDec bd; FP32 fp;
List<Expr>/*!*/ es; List<Variable>/*!*/ ds; Trigger trig;
List<TypeVariable>/*!*/ typeParams;
IdentifierExpr/*!*/ id;
@@ -1742,11 +1742,16 @@ out List<Variable>/*!*/ ins, out List<Variable>/*!*/ outs, out QKeyValue kv) {
e = new LiteralExpr(t, bn);
break;
}
- case 5: case 6: {
+ case 5: {
Dec(out bd);
e = new LiteralExpr(t, bd);
break;
}
+ case 6: {
+ Float(out fp);
+ e = new LiteralExpr(t, fp);
+ break;
+ }
case 2: {
BvLit(out bn, out n);
e = new LiteralExpr(t, bn, n);
@@ -1856,6 +1861,21 @@ out List<Variable>/*!*/ ins, out List<Variable>/*!*/ outs, out QKeyValue kv) {
}
+ void Float(out FP32 n)
+ {
+ string s = "";
+ if (la.kind == 6) {
+ Get();
+ s = t.val;
+ } else SynErr(126);
+ try {
+ n = FP32.FromString(s);
+ } catch (FormatException) {
+ this.SemErr("incorrectly formatted number");
+ n = FP32.ZERO;
+ }
+ }
+
void BvLit(out BigNum n, out int m) {
Expect(2);
int pos = t.val.IndexOf("bv");