summaryrefslogtreecommitdiff
path: root/Source/Dafny/Scanner.cs
diff options
context:
space:
mode:
authorGravatar parno <unknown>2013-07-30 15:25:31 -0700
committerGravatar parno <unknown>2013-07-30 15:25:31 -0700
commit422b0482cb5c4e1e1ac31ba818d0e6ad08022ff6 (patch)
tree632e380d318eb354a2616a6ac4aa16ea86a7a823 /Source/Dafny/Scanner.cs
parentbb91d92b0e8ff9c290f45f9831a1870c177f8de2 (diff)
Add support for hexidecimal numbers.
Diffstat (limited to 'Source/Dafny/Scanner.cs')
-rw-r--r--Source/Dafny/Scanner.cs433
1 files changed, 223 insertions, 210 deletions
diff --git a/Source/Dafny/Scanner.cs b/Source/Dafny/Scanner.cs
index 25aa084a..75ca57bb 100644
--- a/Source/Dafny/Scanner.cs
+++ b/Source/Dafny/Scanner.cs
@@ -211,8 +211,8 @@ public class UTF8Buffer: Buffer {
public class Scanner {
const char EOL = '\n';
const int eofSym = 0; /* pdt */
- const int maxT = 119;
- const int noSym = 119;
+ const int maxT = 120;
+ const int noSym = 120;
[ContractInvariantMethod]
@@ -255,44 +255,45 @@ public class Scanner {
for (int i = 92; i <= 92; ++i) start[i] = 1;
for (int i = 95; i <= 95; ++i) start[i] = 1;
for (int i = 98; i <= 122; ++i) start[i] = 1;
- for (int i = 48; i <= 57; ++i) start[i] = 7;
- for (int i = 34; i <= 34; ++i) start[i] = 8;
- start[97] = 17;
- start[58] = 59;
- start[123] = 10;
- start[125] = 11;
- start[40] = 12;
- start[42] = 13;
- start[33] = 60;
- start[61] = 61;
- start[59] = 24;
- start[46] = 62;
- start[124] = 63;
- start[44] = 25;
- start[41] = 26;
- start[60] = 64;
- start[62] = 65;
- start[96] = 28;
- start[91] = 31;
- start[93] = 32;
- start[35] = 34;
- start[8800] = 37;
- start[8804] = 38;
- start[8805] = 39;
- start[8660] = 41;
- start[8658] = 43;
- start[8656] = 44;
- start[38] = 45;
- start[8743] = 47;
- start[8744] = 49;
- start[43] = 50;
- start[45] = 51;
- start[47] = 52;
- start[37] = 53;
- start[172] = 54;
- start[8704] = 55;
- start[8707] = 56;
- start[8226] = 58;
+ for (int i = 49; i <= 57; ++i) start[i] = 7;
+ for (int i = 34; i <= 34; ++i) start[i] = 10;
+ start[97] = 19;
+ start[48] = 20;
+ start[58] = 62;
+ start[123] = 12;
+ start[125] = 13;
+ start[40] = 14;
+ start[42] = 15;
+ start[33] = 63;
+ start[61] = 64;
+ start[59] = 27;
+ start[46] = 65;
+ start[124] = 66;
+ start[44] = 28;
+ start[41] = 29;
+ start[60] = 67;
+ start[62] = 68;
+ start[96] = 31;
+ start[91] = 34;
+ start[93] = 35;
+ start[35] = 37;
+ start[8800] = 40;
+ start[8804] = 41;
+ start[8805] = 42;
+ start[8660] = 44;
+ start[8658] = 46;
+ start[8656] = 47;
+ start[38] = 48;
+ start[8743] = 50;
+ start[8744] = 52;
+ start[43] = 53;
+ start[45] = 54;
+ start[47] = 55;
+ start[37] = 56;
+ start[172] = 57;
+ start[8704] = 58;
+ start[8707] = 59;
+ start[8226] = 61;
start[Buffer.EOF] = -1;
}
@@ -490,70 +491,70 @@ public class Scanner {
void CheckLiteral() {
switch (t.val) {
- case "abstract": t.kind = 11; break;
- case "module": t.kind = 12; break;
- case "refines": t.kind = 13; break;
- case "import": t.kind = 14; break;
- case "opened": t.kind = 15; break;
- case "as": t.kind = 17; break;
- case "default": t.kind = 18; break;
- case "class": t.kind = 21; break;
- case "ghost": t.kind = 22; break;
- case "static": t.kind = 23; break;
- case "datatype": t.kind = 24; break;
- case "codatatype": t.kind = 25; break;
- case "var": t.kind = 27; break;
- case "type": t.kind = 29; break;
- case "iterator": t.kind = 32; break;
- case "yields": t.kind = 33; break;
- case "returns": t.kind = 34; break;
- case "method": t.kind = 38; break;
- case "comethod": t.kind = 39; break;
- case "constructor": t.kind = 40; break;
- case "modifies": t.kind = 41; break;
- case "free": t.kind = 42; break;
- case "requires": t.kind = 43; break;
- case "ensures": t.kind = 44; break;
- case "decreases": t.kind = 45; break;
- case "reads": t.kind = 46; break;
- case "yield": t.kind = 47; break;
- case "bool": t.kind = 48; break;
- case "nat": t.kind = 49; break;
- case "int": t.kind = 50; break;
- case "set": t.kind = 51; break;
- case "multiset": t.kind = 52; break;
- case "seq": t.kind = 53; break;
- case "map": t.kind = 54; break;
- case "object": t.kind = 55; break;
- case "function": t.kind = 56; break;
- case "predicate": t.kind = 57; break;
- case "copredicate": t.kind = 58; break;
- case "label": t.kind = 60; break;
- case "break": t.kind = 61; break;
- case "where": t.kind = 62; break;
- case "return": t.kind = 64; break;
- case "assume": t.kind = 66; break;
- case "new": t.kind = 67; break;
- case "if": t.kind = 70; break;
- case "else": t.kind = 71; break;
- case "case": t.kind = 72; break;
- case "while": t.kind = 74; break;
- case "invariant": t.kind = 75; break;
- case "match": t.kind = 76; break;
- case "assert": t.kind = 77; break;
- case "print": t.kind = 78; break;
- case "forall": t.kind = 79; break;
- case "parallel": t.kind = 80; break;
- case "calc": t.kind = 81; break;
- case "in": t.kind = 99; break;
- case "false": t.kind = 106; break;
- case "true": t.kind = 107; break;
- case "null": t.kind = 108; break;
- case "this": t.kind = 109; break;
- case "fresh": t.kind = 110; break;
- case "old": t.kind = 111; break;
- case "then": t.kind = 112; break;
- case "exists": t.kind = 115; break;
+ case "abstract": t.kind = 12; break;
+ case "module": t.kind = 13; break;
+ case "refines": t.kind = 14; break;
+ case "import": t.kind = 15; break;
+ case "opened": t.kind = 16; break;
+ case "as": t.kind = 18; break;
+ case "default": t.kind = 19; break;
+ case "class": t.kind = 22; break;
+ case "ghost": t.kind = 23; break;
+ case "static": t.kind = 24; break;
+ case "datatype": t.kind = 25; break;
+ case "codatatype": t.kind = 26; break;
+ case "var": t.kind = 28; break;
+ case "type": t.kind = 30; break;
+ case "iterator": t.kind = 33; break;
+ case "yields": t.kind = 34; break;
+ case "returns": t.kind = 35; break;
+ case "method": t.kind = 39; break;
+ case "comethod": t.kind = 40; break;
+ case "constructor": t.kind = 41; break;
+ case "modifies": t.kind = 42; break;
+ case "free": t.kind = 43; break;
+ case "requires": t.kind = 44; break;
+ case "ensures": t.kind = 45; break;
+ case "decreases": t.kind = 46; break;
+ case "reads": t.kind = 47; break;
+ case "yield": t.kind = 48; break;
+ case "bool": t.kind = 49; break;
+ case "nat": t.kind = 50; break;
+ case "int": t.kind = 51; break;
+ case "set": t.kind = 52; break;
+ case "multiset": t.kind = 53; break;
+ case "seq": t.kind = 54; break;
+ case "map": t.kind = 55; break;
+ case "object": t.kind = 56; break;
+ case "function": t.kind = 57; break;
+ case "predicate": t.kind = 58; break;
+ case "copredicate": t.kind = 59; break;
+ case "label": t.kind = 61; break;
+ case "break": t.kind = 62; break;
+ case "where": t.kind = 63; break;
+ case "return": t.kind = 65; break;
+ case "assume": t.kind = 67; break;
+ case "new": t.kind = 68; break;
+ case "if": t.kind = 71; break;
+ case "else": t.kind = 72; break;
+ case "case": t.kind = 73; break;
+ case "while": t.kind = 75; break;
+ case "invariant": t.kind = 76; break;
+ case "match": t.kind = 77; break;
+ case "assert": t.kind = 78; break;
+ case "print": t.kind = 79; break;
+ case "forall": t.kind = 80; break;
+ case "parallel": t.kind = 81; break;
+ case "calc": t.kind = 82; break;
+ case "in": t.kind = 100; break;
+ case "false": t.kind = 107; break;
+ case "true": t.kind = 108; break;
+ case "null": t.kind = 109; break;
+ case "this": t.kind = 110; break;
+ case "fresh": t.kind = 111; break;
+ case "old": t.kind = 112; break;
+ case "then": t.kind = 113; break;
+ case "exists": t.kind = 116; break;
default: break;
}
}
@@ -616,183 +617,195 @@ public class Scanner {
if (ch >= '0' && ch <= '9') {AddCh(); goto case 7;}
else {t.kind = 2; break;}
case 8:
- if (ch == '"') {AddCh(); goto case 9;}
- else if (ch >= ' ' && ch <= '!' || ch >= '#' && ch <= '~') {AddCh(); goto case 8;}
+ if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 9;}
else {goto case 0;}
case 9:
- {t.kind = 4; break;}
+ recEnd = pos; recKind = 3;
+ if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 9;}
+ else {t.kind = 3; break;}
case 10:
- {t.kind = 6; break;}
+ if (ch == '"') {AddCh(); goto case 11;}
+ else if (ch >= ' ' && ch <= '!' || ch >= '#' && ch <= '~') {AddCh(); goto case 10;}
+ else {goto case 0;}
case 11:
- {t.kind = 7; break;}
+ {t.kind = 5; break;}
case 12:
- {t.kind = 8; break;}
+ {t.kind = 7; break;}
case 13:
- {t.kind = 9; break;}
+ {t.kind = 8; break;}
case 14:
- if (ch == 'n') {AddCh(); goto case 15;}
- else {goto case 0;}
+ {t.kind = 9; break;}
case 15:
- if (ch <= '&' || ch >= '(' && ch <= '/' || ch >= ':' && ch <= '>' || ch == '@' || ch == '[' || ch >= ']' && ch <= '^' || ch == '`' || ch >= '{' && ch <= 65535) {apx++; AddCh(); goto case 16;}
- else {goto case 0;}
+ {t.kind = 10; break;}
case 16:
+ if (ch == 'n') {AddCh(); goto case 17;}
+ else {goto case 0;}
+ case 17:
+ if (ch <= '&' || ch >= '(' && ch <= '/' || ch >= ':' && ch <= '>' || ch == '@' || ch == '[' || ch >= ']' && ch <= '^' || ch == '`' || ch >= '{' && ch <= 65535) {apx++; AddCh(); goto case 18;}
+ else {goto case 0;}
+ case 18:
{
tlen -= apx;
SetScannerBehindT();
- t.kind = 10; break;}
- case 17:
+ t.kind = 11; break;}
+ case 19:
recEnd = pos; recKind = 1;
if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'q' || ch >= 's' && ch <= 'z') {AddCh(); goto case 2;}
- else if (ch == 'r') {AddCh(); goto case 19;}
+ else if (ch == 'r') {AddCh(); goto case 22;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
- case 18:
+ case 20:
+ recEnd = pos; recKind = 2;
+ if (ch >= '0' && ch <= '9') {AddCh(); goto case 7;}
+ else if (ch == 'x') {AddCh(); goto case 8;}
+ else {t.kind = 2; break;}
+ case 21:
recEnd = pos; recKind = 1;
- if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 18;}
+ if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 21;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
- case 19:
+ case 22:
recEnd = pos; recKind = 1;
if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'q' || ch >= 's' && ch <= 'z') {AddCh(); goto case 3;}
- else if (ch == 'r') {AddCh(); goto case 20;}
+ else if (ch == 'r') {AddCh(); goto case 23;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
- case 20:
+ case 23:
recEnd = pos; recKind = 1;
if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'b' && ch <= 'z') {AddCh(); goto case 4;}
- else if (ch == 'a') {AddCh(); goto case 21;}
+ else if (ch == 'a') {AddCh(); goto case 24;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
- case 21:
+ case 24:
recEnd = pos; recKind = 1;
if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'x' || ch == 'z') {AddCh(); goto case 5;}
- else if (ch == 'y') {AddCh(); goto case 22;}
+ else if (ch == 'y') {AddCh(); goto case 25;}
else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
- case 22:
- recEnd = pos; recKind = 3;
- if (ch == 39 || ch == '0' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 6;}
- else if (ch >= '1' && ch <= '9') {AddCh(); goto case 23;}
- else {t.kind = 3; break;}
- case 23:
- recEnd = pos; recKind = 3;
- if (ch == 39 || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 18;}
- else if (ch >= '0' && ch <= '9') {AddCh(); goto case 23;}
- else {t.kind = 3; break;}
- case 24:
- {t.kind = 19; break;}
case 25:
- {t.kind = 28; break;}
+ recEnd = pos; recKind = 4;
+ if (ch == 39 || ch == '0' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 6;}
+ else if (ch >= '1' && ch <= '9') {AddCh(); goto case 26;}
+ else {t.kind = 4; break;}
case 26:
- {t.kind = 31; break;}
+ recEnd = pos; recKind = 4;
+ if (ch == 39 || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == 92 || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 21;}
+ else if (ch >= '0' && ch <= '9') {AddCh(); goto case 26;}
+ else {t.kind = 4; break;}
case 27:
- {t.kind = 35; break;}
+ {t.kind = 20; break;}
case 28:
- {t.kind = 59; break;}
+ {t.kind = 29; break;}
case 29:
- {t.kind = 63; break;}
+ {t.kind = 32; break;}
case 30:
- {t.kind = 65; break;}
+ {t.kind = 36; break;}
case 31:
- {t.kind = 68; break;}
+ {t.kind = 60; break;}
case 32:
- {t.kind = 69; break;}
+ {t.kind = 64; break;}
case 33:
- {t.kind = 73; break;}
+ {t.kind = 66; break;}
case 34:
- {t.kind = 82; break;}
+ {t.kind = 69; break;}
case 35:
- {t.kind = 84; break;}
+ {t.kind = 70; break;}
case 36:
- {t.kind = 85; break;}
+ {t.kind = 74; break;}
case 37:
- {t.kind = 86; break;}
+ {t.kind = 83; break;}
case 38:
- {t.kind = 87; break;}
+ {t.kind = 85; break;}
case 39:
- {t.kind = 88; break;}
+ {t.kind = 86; break;}
case 40:
- {t.kind = 89; break;}
+ {t.kind = 87; break;}
case 41:
- {t.kind = 90; break;}
+ {t.kind = 88; break;}
case 42:
- {t.kind = 91; break;}
+ {t.kind = 89; break;}
case 43:
- {t.kind = 92; break;}
+ {t.kind = 90; break;}
case 44:
- {t.kind = 94; break;}
+ {t.kind = 91; break;}
case 45:
- if (ch == '&') {AddCh(); goto case 46;}
- else {goto case 0;}
+ {t.kind = 92; break;}
case 46:
- {t.kind = 95; break;}
+ {t.kind = 93; break;}
case 47:
- {t.kind = 96; break;}
+ {t.kind = 95; break;}
case 48:
- {t.kind = 97; break;}
+ if (ch == '&') {AddCh(); goto case 49;}
+ else {goto case 0;}
case 49:
- {t.kind = 98; break;}
+ {t.kind = 96; break;}
case 50:
- {t.kind = 101; break;}
+ {t.kind = 97; break;}
case 51:
- {t.kind = 102; break;}
+ {t.kind = 98; break;}
case 52:
- {t.kind = 103; break;}
+ {t.kind = 99; break;}
case 53:
- {t.kind = 104; break;}
+ {t.kind = 102; break;}
case 54:
- {t.kind = 105; break;}
+ {t.kind = 103; break;}
case 55:
- {t.kind = 114; break;}
+ {t.kind = 104; break;}
case 56:
- {t.kind = 116; break;}
+ {t.kind = 105; break;}
case 57:
- {t.kind = 117; break;}
+ {t.kind = 106; break;}
case 58:
- {t.kind = 118; break;}
+ {t.kind = 115; break;}
case 59:
- recEnd = pos; recKind = 5;
- if (ch == '=') {AddCh(); goto case 29;}
- else if (ch == '|') {AddCh(); goto case 30;}
- else if (ch == ':') {AddCh(); goto case 57;}
- else {t.kind = 5; break;}
+ {t.kind = 117; break;}
case 60:
- recEnd = pos; recKind = 100;
- if (ch == 'i') {AddCh(); goto case 14;}
- else if (ch == '=') {AddCh(); goto case 36;}
- else {t.kind = 100; break;}
+ {t.kind = 118; break;}
case 61:
- recEnd = pos; recKind = 16;
- if (ch == '=') {AddCh(); goto case 66;}
- else if (ch == '>') {AddCh(); goto case 33;}
- else {t.kind = 16; break;}
+ {t.kind = 119; break;}
case 62:
- recEnd = pos; recKind = 20;
- if (ch == '.') {AddCh(); goto case 67;}
- else {t.kind = 20; break;}
+ recEnd = pos; recKind = 6;
+ if (ch == '=') {AddCh(); goto case 32;}
+ else if (ch == '|') {AddCh(); goto case 33;}
+ else if (ch == ':') {AddCh(); goto case 60;}
+ else {t.kind = 6; break;}
case 63:
- recEnd = pos; recKind = 26;
- if (ch == '|') {AddCh(); goto case 48;}
- else {t.kind = 26; break;}
+ recEnd = pos; recKind = 101;
+ if (ch == 'i') {AddCh(); goto case 16;}
+ else if (ch == '=') {AddCh(); goto case 39;}
+ else {t.kind = 101; break;}
case 64:
- recEnd = pos; recKind = 36;
- if (ch == '=') {AddCh(); goto case 68;}
- else {t.kind = 36; break;}
+ recEnd = pos; recKind = 17;
+ if (ch == '=') {AddCh(); goto case 69;}
+ else if (ch == '>') {AddCh(); goto case 36;}
+ else {t.kind = 17; break;}
case 65:
- recEnd = pos; recKind = 37;
- if (ch == '=') {AddCh(); goto case 35;}
- else {t.kind = 37; break;}
+ recEnd = pos; recKind = 21;
+ if (ch == '.') {AddCh(); goto case 70;}
+ else {t.kind = 21; break;}
case 66:
- recEnd = pos; recKind = 30;
- if (ch == '>') {AddCh(); goto case 42;}
- else {t.kind = 30; break;}
+ recEnd = pos; recKind = 27;
+ if (ch == '|') {AddCh(); goto case 51;}
+ else {t.kind = 27; break;}
case 67:
- recEnd = pos; recKind = 113;
- if (ch == '.') {AddCh(); goto case 27;}
- else {t.kind = 113; break;}
+ recEnd = pos; recKind = 37;
+ if (ch == '=') {AddCh(); goto case 71;}
+ else {t.kind = 37; break;}
case 68:
- recEnd = pos; recKind = 83;
- if (ch == '=') {AddCh(); goto case 69;}
- else {t.kind = 83; break;}
+ recEnd = pos; recKind = 38;
+ if (ch == '=') {AddCh(); goto case 38;}
+ else {t.kind = 38; break;}
case 69:
- recEnd = pos; recKind = 93;
- if (ch == '>') {AddCh(); goto case 40;}
- else {t.kind = 93; break;}
+ recEnd = pos; recKind = 31;
+ if (ch == '>') {AddCh(); goto case 45;}
+ else {t.kind = 31; break;}
+ case 70:
+ recEnd = pos; recKind = 114;
+ if (ch == '.') {AddCh(); goto case 30;}
+ else {t.kind = 114; break;}
+ case 71:
+ recEnd = pos; recKind = 84;
+ if (ch == '=') {AddCh(); goto case 72;}
+ else {t.kind = 84; break;}
+ case 72:
+ recEnd = pos; recKind = 94;
+ if (ch == '>') {AddCh(); goto case 43;}
+ else {t.kind = 94; break;}
}
t.val = new String(tval, 0, tlen);