示例#1
0
 /* skip: { "[" { "," } "]" | "*" }                   */
 /* returns the next token after the pointer of dims  */
 /* or null if not recognized                         */
 /* !!! Proceeds from current peek position !!!       */
 Token SkipPointerOrDims(Token pt)
 {
     for (;;) {
      if (pt.kind == _lbrack) {
     do pt = PeekWithPragmas();
     while (pt.kind == _comma);
     if (pt.kind != _rbrack) return null;
      } else if (pt.kind != _times) break;
      pt = PeekWithPragmas();
       }
       return pt;
 }
示例#2
0
 void Init()
 {
     pos = -1; line = 1; col = 0;
     oldEols = 0;
     NextCh();
     if (ch == 0xEF) { // check optional byte order mark for UTF-8
     NextCh(); int ch1 = ch;
     NextCh(); int ch2 = ch;
     if (ch1 != 0xBB || ch2 != 0xBF) {
         throw new FatalError(String.Format("illegal byte order mark: EF {0,2:X} {1,2:X}", ch1, ch2));
     }
     buffer = new UTF8Buffer(buffer); col = 0;
     NextCh();
     }
     pt = tokens = new Token();  // first token is a dummy
 }
示例#3
0
        Token NextToken()
        {
            while (ch == ' ' ||
            ch >= 9 && ch <= 10 || ch == 13
            ) NextCh();
            if (ch == '/' && Comment0() ||ch == '/' && Comment1()) return NextToken();
            int apx = 0;
            int recKind = noSym;
            int recEnd = pos;
            t = new Token();
            t.pos = pos; t.col = col; t.line = line;
            int state;
            if (start.ContainsKey(ch)) { state = (int) start[ch]; }
            else { state = 0; }
            tlen = 0; AddCh();

            switch (state) {
            case -1: { t.kind = eofSym; break; } // NextCh already done
            case 0: {
                if (recKind != noSym) {
                    tlen = recEnd - t.pos;
                    SetScannerBehindT();
                }
                t.kind = recKind; break;
            } // NextCh already done
            case 1:
                recEnd = pos; recKind = 1;
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z' || ch == 128 || ch >= 160 && ch <= 179 || ch == 181 || ch == 186 || ch >= 192 && ch <= 214 || ch >= 216 && ch <= 246 || ch >= 248 && ch <= 255) {AddCh(); goto case 1;}
                else if (ch == 92) {AddCh(); goto case 2;}
                else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
            case 2:
                if (ch == 'u') {AddCh(); goto case 3;}
                else if (ch == 'U') {AddCh(); goto case 7;}
                else {goto case 0;}
            case 3:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 4;}
                else {goto case 0;}
            case 4:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 5;}
                else {goto case 0;}
            case 5:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 6;}
                else {goto case 0;}
            case 6:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 1;}
                else {goto case 0;}
            case 7:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 8;}
                else {goto case 0;}
            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:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 10;}
                else {goto case 0;}
            case 10:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 11;}
                else {goto case 0;}
            case 11:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 12;}
                else {goto case 0;}
            case 12:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 13;}
                else {goto case 0;}
            case 13:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 14;}
                else {goto case 0;}
            case 14:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 1;}
                else {goto case 0;}
            case 15:
                if (ch == 'u') {AddCh(); goto case 16;}
                else if (ch == 'U') {AddCh(); goto case 20;}
                else {goto case 0;}
            case 16:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 17;}
                else {goto case 0;}
            case 17:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 18;}
                else {goto case 0;}
            case 18:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 19;}
                else {goto case 0;}
            case 19:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 1;}
                else {goto case 0;}
            case 20:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 21;}
                else {goto case 0;}
            case 21:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 22;}
                else {goto case 0;}
            case 22:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 23;}
                else {goto case 0;}
            case 23:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 24;}
                else {goto case 0;}
            case 24:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 25;}
                else {goto case 0;}
            case 25:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 26;}
                else {goto case 0;}
            case 26:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 27;}
                else {goto case 0;}
            case 27:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 1;}
                else {goto case 0;}
            case 28:
                {
                    tlen -= apx;
                    SetScannerBehindT();
                    t.kind = 2; break;}
            case 29:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 30;}
                else {goto case 0;}
            case 30:
                recEnd = pos; recKind = 2;
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 30;}
                else if (ch == 'U') {AddCh(); goto case 176;}
                else if (ch == 'u') {AddCh(); goto case 177;}
                else if (ch == 'L') {AddCh(); goto case 178;}
                else if (ch == 'l') {AddCh(); goto case 179;}
                else {t.kind = 2; break;}
            case 31:
                {t.kind = 2; break;}
            case 32:
                recEnd = pos; recKind = 3;
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 32;}
                else if (ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm') {AddCh(); goto case 43;}
                else if (ch == 'E' || ch == 'e') {AddCh(); goto case 33;}
                else {t.kind = 3; break;}
            case 33:
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 35;}
                else if (ch == '+' || ch == '-') {AddCh(); goto case 34;}
                else {goto case 0;}
            case 34:
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 35;}
                else {goto case 0;}
            case 35:
                recEnd = pos; recKind = 3;
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 35;}
                else if (ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm') {AddCh(); goto case 43;}
                else {t.kind = 3; break;}
            case 36:
                recEnd = pos; recKind = 3;
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 36;}
                else if (ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm') {AddCh(); goto case 43;}
                else if (ch == 'E' || ch == 'e') {AddCh(); goto case 37;}
                else {t.kind = 3; break;}
            case 37:
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 39;}
                else if (ch == '+' || ch == '-') {AddCh(); goto case 38;}
                else {goto case 0;}
            case 38:
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 39;}
                else {goto case 0;}
            case 39:
                recEnd = pos; recKind = 3;
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 39;}
                else if (ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm') {AddCh(); goto case 43;}
                else {t.kind = 3; break;}
            case 40:
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 42;}
                else if (ch == '+' || ch == '-') {AddCh(); goto case 41;}
                else {goto case 0;}
            case 41:
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 42;}
                else {goto case 0;}
            case 42:
                recEnd = pos; recKind = 3;
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 42;}
                else if (ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm') {AddCh(); goto case 43;}
                else {t.kind = 3; break;}
            case 43:
                {t.kind = 3; break;}
            case 44:
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '&' || ch >= '(' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); goto case 45;}
                else if (ch == 92) {AddCh(); goto case 180;}
                else {goto case 0;}
            case 45:
                if (ch == 39) {AddCh(); goto case 60;}
                else {goto case 0;}
            case 46:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 47;}
                else {goto case 0;}
            case 47:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 181;}
                else if (ch == 39) {AddCh(); goto case 60;}
                else {goto case 0;}
            case 48:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 49;}
                else {goto case 0;}
            case 49:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 50;}
                else {goto case 0;}
            case 50:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 51;}
                else {goto case 0;}
            case 51:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 45;}
                else {goto case 0;}
            case 52:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 53;}
                else {goto case 0;}
            case 53:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 54;}
                else {goto case 0;}
            case 54:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 55;}
                else {goto case 0;}
            case 55:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 56;}
                else {goto case 0;}
            case 56:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 57;}
                else {goto case 0;}
            case 57:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 58;}
                else {goto case 0;}
            case 58:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 59;}
                else {goto case 0;}
            case 59:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 45;}
                else {goto case 0;}
            case 60:
                {t.kind = 4; break;}
            case 61:
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); goto case 61;}
                else if (ch == '"') {AddCh(); goto case 77;}
                else if (ch == 92) {AddCh(); goto case 183;}
                else {goto case 0;}
            case 62:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 63;}
                else {goto case 0;}
            case 63:
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '/' || ch >= ':' && ch <= '@' || ch >= 'G' && ch <= '[' || ch >= ']' && ch <= '`' || ch >= 'g' && ch <= 65535) {AddCh(); goto case 61;}
                else if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 184;}
                else if (ch == '"') {AddCh(); goto case 77;}
                else if (ch == 92) {AddCh(); goto case 183;}
                else {goto case 0;}
            case 64:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 65;}
                else {goto case 0;}
            case 65:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 66;}
                else {goto case 0;}
            case 66:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 67;}
                else {goto case 0;}
            case 67:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 61;}
                else {goto case 0;}
            case 68:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 69;}
                else {goto case 0;}
            case 69:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 70;}
                else {goto case 0;}
            case 70:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 71;}
                else {goto case 0;}
            case 71:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 72;}
                else {goto case 0;}
            case 72:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 73;}
                else {goto case 0;}
            case 73:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 74;}
                else {goto case 0;}
            case 74:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 75;}
                else {goto case 0;}
            case 75:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 61;}
                else {goto case 0;}
            case 76:
                if (ch <= '!' || ch >= '#' && ch <= 65535) {AddCh(); goto case 76;}
                else if (ch == '"') {AddCh(); goto case 186;}
                else {goto case 0;}
            case 77:
                {t.kind = 5; break;}
            case 78:
                {t.kind = 84; break;}
            case 79:
                {t.kind = 85; break;}
            case 80:
                {t.kind = 88; break;}
            case 81:
                {t.kind = 89; break;}
            case 82:
                {t.kind = 90; break;}
            case 83:
                {t.kind = 92; break;}
            case 84:
                {t.kind = 93; break;}
            case 85:
                {t.kind = 95; break;}
            case 86:
                {t.kind = 96; break;}
            case 87:
                {t.kind = 97; break;}
            case 88:
                {t.kind = 98; break;}
            case 89:
                {t.kind = 99; break;}
            case 90:
                {t.kind = 100; break;}
            case 91:
                {t.kind = 104; break;}
            case 92:
                {t.kind = 105; break;}
            case 93:
                {t.kind = 106; break;}
            case 94:
                {t.kind = 108; break;}
            case 95:
                {t.kind = 109; break;}
            case 96:
                {t.kind = 111; break;}
            case 97:
                {t.kind = 113; break;}
            case 98:
                {t.kind = 114; break;}
            case 99:
                {t.kind = 115; break;}
            case 100:
                {t.kind = 116; break;}
            case 101:
                {t.kind = 117; break;}
            case 102:
                {t.kind = 119; break;}
            case 103:
                {t.kind = 120; break;}
            case 104:
                {t.kind = 121; break;}
            case 105:
                {t.kind = 122; break;}
            case 106:
                if (ch == 'e') {AddCh(); goto case 107;}
                else {goto case 0;}
            case 107:
                if (ch == 'f') {AddCh(); goto case 108;}
                else {goto case 0;}
            case 108:
                if (ch == 'i') {AddCh(); goto case 109;}
                else {goto case 0;}
            case 109:
                if (ch == 'n') {AddCh(); goto case 110;}
                else {goto case 0;}
            case 110:
                if (ch == 'e') {AddCh(); goto case 111;}
                else {goto case 0;}
            case 111:
                recEnd = pos; recKind = 143;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 111;}
                else {t.kind = 143; break;}
            case 112:
                if (ch == 'n') {AddCh(); goto case 113;}
                else {goto case 0;}
            case 113:
                if (ch == 'd') {AddCh(); goto case 114;}
                else {goto case 0;}
            case 114:
                if (ch == 'e') {AddCh(); goto case 115;}
                else {goto case 0;}
            case 115:
                if (ch == 'f') {AddCh(); goto case 116;}
                else {goto case 0;}
            case 116:
                recEnd = pos; recKind = 144;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 116;}
                else {t.kind = 144; break;}
            case 117:
                if (ch == 'f') {AddCh(); goto case 118;}
                else {goto case 0;}
            case 118:
                recEnd = pos; recKind = 145;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 118;}
                else {t.kind = 145; break;}
            case 119:
                if (ch == 'f') {AddCh(); goto case 120;}
                else {goto case 0;}
            case 120:
                recEnd = pos; recKind = 146;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 120;}
                else {t.kind = 146; break;}
            case 121:
                if (ch == 'e') {AddCh(); goto case 122;}
                else {goto case 0;}
            case 122:
                recEnd = pos; recKind = 147;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 122;}
                else {t.kind = 147; break;}
            case 123:
                if (ch == 'f') {AddCh(); goto case 124;}
                else {goto case 0;}
            case 124:
                recEnd = pos; recKind = 148;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 124;}
                else {t.kind = 148; break;}
            case 125:
                if (ch == 'i') {AddCh(); goto case 126;}
                else {goto case 0;}
            case 126:
                if (ch == 'n') {AddCh(); goto case 127;}
                else {goto case 0;}
            case 127:
                if (ch == 'e') {AddCh(); goto case 128;}
                else {goto case 0;}
            case 128:
                recEnd = pos; recKind = 149;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 128;}
                else {t.kind = 149; break;}
            case 129:
                if (ch == 'r') {AddCh(); goto case 130;}
                else {goto case 0;}
            case 130:
                if (ch == 'o') {AddCh(); goto case 131;}
                else {goto case 0;}
            case 131:
                if (ch == 'r') {AddCh(); goto case 132;}
                else {goto case 0;}
            case 132:
                recEnd = pos; recKind = 150;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 132;}
                else {t.kind = 150; break;}
            case 133:
                if (ch == 'a') {AddCh(); goto case 134;}
                else {goto case 0;}
            case 134:
                if (ch == 'r') {AddCh(); goto case 135;}
                else {goto case 0;}
            case 135:
                if (ch == 'n') {AddCh(); goto case 136;}
                else {goto case 0;}
            case 136:
                if (ch == 'i') {AddCh(); goto case 137;}
                else {goto case 0;}
            case 137:
                if (ch == 'n') {AddCh(); goto case 138;}
                else {goto case 0;}
            case 138:
                if (ch == 'g') {AddCh(); goto case 139;}
                else {goto case 0;}
            case 139:
                recEnd = pos; recKind = 151;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 139;}
                else {t.kind = 151; break;}
            case 140:
                if (ch == 'e') {AddCh(); goto case 141;}
                else {goto case 0;}
            case 141:
                if (ch == 'g') {AddCh(); goto case 142;}
                else {goto case 0;}
            case 142:
                if (ch == 'i') {AddCh(); goto case 143;}
                else {goto case 0;}
            case 143:
                if (ch == 'o') {AddCh(); goto case 144;}
                else {goto case 0;}
            case 144:
                if (ch == 'n') {AddCh(); goto case 145;}
                else {goto case 0;}
            case 145:
                recEnd = pos; recKind = 152;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 145;}
                else {t.kind = 152; break;}
            case 146:
                if (ch == 'e') {AddCh(); goto case 147;}
                else {goto case 0;}
            case 147:
                if (ch == 'g') {AddCh(); goto case 148;}
                else {goto case 0;}
            case 148:
                if (ch == 'i') {AddCh(); goto case 149;}
                else {goto case 0;}
            case 149:
                if (ch == 'o') {AddCh(); goto case 150;}
                else {goto case 0;}
            case 150:
                if (ch == 'n') {AddCh(); goto case 151;}
                else {goto case 0;}
            case 151:
                recEnd = pos; recKind = 153;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 151;}
                else {t.kind = 153; break;}
            case 152:
                if (ch == 'r') {AddCh(); goto case 153;}
                else {goto case 0;}
            case 153:
                if (ch == 'a') {AddCh(); goto case 154;}
                else {goto case 0;}
            case 154:
                if (ch == 'g') {AddCh(); goto case 155;}
                else {goto case 0;}
            case 155:
                if (ch == 'm') {AddCh(); goto case 156;}
                else {goto case 0;}
            case 156:
                if (ch == 'a') {AddCh(); goto case 157;}
                else {goto case 0;}
            case 157:
                recEnd = pos; recKind = 154;
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 65535) {AddCh(); goto case 157;}
                else {t.kind = 154; break;}
            case 158:
                recEnd = pos; recKind = 2;
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 158;}
                else if (ch == 'U') {AddCh(); goto case 172;}
                else if (ch == 'u') {AddCh(); goto case 173;}
                else if (ch == 'L') {AddCh(); goto case 174;}
                else if (ch == 'l') {AddCh(); goto case 175;}
                else if (ch == '.') {apx++; AddCh(); goto case 187;}
                else if (ch == 'E' || ch == 'e') {AddCh(); goto case 40;}
                else if (ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm') {AddCh(); goto case 43;}
                else {t.kind = 2; break;}
            case 159:
                if (ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z' || ch == 170 || ch == 181 || ch == 186 || ch >= 192 && ch <= 214 || ch >= 216 && ch <= 246 || ch >= 248 && ch <= 255) {AddCh(); goto case 1;}
                else if (ch == 92) {AddCh(); goto case 15;}
                else if (ch == '"') {AddCh(); goto case 76;}
                else {goto case 0;}
            case 160:
                recEnd = pos; recKind = 2;
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 158;}
                else if (ch == 'U') {AddCh(); goto case 172;}
                else if (ch == 'u') {AddCh(); goto case 173;}
                else if (ch == 'L') {AddCh(); goto case 174;}
                else if (ch == 'l') {AddCh(); goto case 175;}
                else if (ch == '.') {apx++; AddCh(); goto case 187;}
                else if (ch == 'X' || ch == 'x') {AddCh(); goto case 29;}
                else if (ch == 'E' || ch == 'e') {AddCh(); goto case 40;}
                else if (ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm') {AddCh(); goto case 43;}
                else {t.kind = 2; break;}
            case 161:
                recEnd = pos; recKind = 91;
                if (ch >= '0' && ch <= '9') {AddCh(); goto case 32;}
                else {t.kind = 91; break;}
            case 162:
                recEnd = pos; recKind = 83;
                if (ch == '=') {AddCh(); goto case 78;}
                else if (ch == '&') {AddCh(); goto case 104;}
                else {t.kind = 83; break;}
            case 163:
                recEnd = pos; recKind = 86;
                if (ch == '>') {AddCh(); goto case 79;}
                else if (ch == '=') {AddCh(); goto case 84;}
                else {t.kind = 86; break;}
            case 164:
                recEnd = pos; recKind = 87;
                if (ch == ':') {AddCh(); goto case 83;}
                else {t.kind = 87; break;}
            case 165:
                recEnd = pos; recKind = 94;
                if (ch == '=') {AddCh(); goto case 85;}
                else {t.kind = 94; break;}
            case 166:
                recEnd = pos; recKind = 110;
                if (ch == '+') {AddCh(); goto case 86;}
                else if (ch == '=') {AddCh(); goto case 96;}
                else {t.kind = 110; break;}
            case 167:
                recEnd = pos; recKind = 101;
                if (ch == '<') {AddCh(); goto case 188;}
                else if (ch == '=') {AddCh(); goto case 105;}
                else {t.kind = 101; break;}
            case 168:
                recEnd = pos; recKind = 107;
                if (ch == '=') {AddCh(); goto case 93;}
                else {t.kind = 107; break;}
            case 169:
                recEnd = pos; recKind = 112;
                if (ch == '?') {AddCh(); goto case 94;}
                else {t.kind = 112; break;}
            case 170:
                recEnd = pos; recKind = 118;
                if (ch == '=') {AddCh(); goto case 102;}
                else {t.kind = 118; break;}
            case 171:
                if (ch == 9 || ch >= 11 && ch <= 12 || ch == ' ') {AddCh(); goto case 171;}
                else if (ch == 'd') {AddCh(); goto case 106;}
                else if (ch == 'u') {AddCh(); goto case 112;}
                else if (ch == 'i') {AddCh(); goto case 117;}
                else if (ch == 'e') {AddCh(); goto case 189;}
                else if (ch == 'l') {AddCh(); goto case 125;}
                else if (ch == 'w') {AddCh(); goto case 133;}
                else if (ch == 'r') {AddCh(); goto case 140;}
                else if (ch == 'p') {AddCh(); goto case 152;}
                else {goto case 0;}
            case 172:
                recEnd = pos; recKind = 2;
                if (ch == 'L' || ch == 'l') {AddCh(); goto case 31;}
                else {t.kind = 2; break;}
            case 173:
                recEnd = pos; recKind = 2;
                if (ch == 'L' || ch == 'l') {AddCh(); goto case 31;}
                else {t.kind = 2; break;}
            case 174:
                recEnd = pos; recKind = 2;
                if (ch == 'U' || ch == 'u') {AddCh(); goto case 31;}
                else {t.kind = 2; break;}
            case 175:
                recEnd = pos; recKind = 2;
                if (ch == 'U' || ch == 'u') {AddCh(); goto case 31;}
                else {t.kind = 2; break;}
            case 176:
                recEnd = pos; recKind = 2;
                if (ch == 'L' || ch == 'l') {AddCh(); goto case 31;}
                else {t.kind = 2; break;}
            case 177:
                recEnd = pos; recKind = 2;
                if (ch == 'L' || ch == 'l') {AddCh(); goto case 31;}
                else {t.kind = 2; break;}
            case 178:
                recEnd = pos; recKind = 2;
                if (ch == 'U' || ch == 'u') {AddCh(); goto case 31;}
                else {t.kind = 2; break;}
            case 179:
                recEnd = pos; recKind = 2;
                if (ch == 'U' || ch == 'u') {AddCh(); goto case 31;}
                else {t.kind = 2; break;}
            case 180:
                if (ch == '"' || ch == 39 || ch == '0' || ch == 92 || ch >= 'a' && ch <= 'b' || ch == 'f' || ch == 'n' || ch == 'r' || ch == 't' || ch == 'v') {AddCh(); goto case 45;}
                else if (ch == 'x') {AddCh(); goto case 46;}
                else if (ch == 'u') {AddCh(); goto case 48;}
                else if (ch == 'U') {AddCh(); goto case 52;}
                else {goto case 0;}
            case 181:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 182;}
                else if (ch == 39) {AddCh(); goto case 60;}
                else {goto case 0;}
            case 182:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 45;}
                else if (ch == 39) {AddCh(); goto case 60;}
                else {goto case 0;}
            case 183:
                if (ch == '"' || ch == 39 || ch == '0' || ch == 92 || ch >= 'a' && ch <= 'b' || ch == 'f' || ch == 'n' || ch == 'r' || ch == 't' || ch == 'v') {AddCh(); goto case 61;}
                else if (ch == 'x') {AddCh(); goto case 62;}
                else if (ch == 'u') {AddCh(); goto case 64;}
                else if (ch == 'U') {AddCh(); goto case 68;}
                else {goto case 0;}
            case 184:
                if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 185;}
                else if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '/' || ch >= ':' && ch <= '@' || ch >= 'G' && ch <= '[' || ch >= ']' && ch <= '`' || ch >= 'g' && ch <= 65535) {AddCh(); goto case 61;}
                else if (ch == '"') {AddCh(); goto case 77;}
                else if (ch == 92) {AddCh(); goto case 183;}
                else {goto case 0;}
            case 185:
                if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); goto case 61;}
                else if (ch == '"') {AddCh(); goto case 77;}
                else if (ch == 92) {AddCh(); goto case 183;}
                else {goto case 0;}
            case 186:
                recEnd = pos; recKind = 5;
                if (ch == '"') {AddCh(); goto case 76;}
                else {t.kind = 5; break;}
            case 187:
                if (ch <= '/' || ch >= ':' && ch <= 65535) {apx++; AddCh(); goto case 28;}
                else if (ch >= '0' && ch <= '9') {apx = 0; AddCh(); goto case 36;}
                else {goto case 0;}
            case 188:
                recEnd = pos; recKind = 102;
                if (ch == '=') {AddCh(); goto case 90;}
                else {t.kind = 102; break;}
            case 189:
                if (ch == 'l') {AddCh(); goto case 190;}
                else if (ch == 'n') {AddCh(); goto case 191;}
                else if (ch == 'r') {AddCh(); goto case 129;}
                else {goto case 0;}
            case 190:
                if (ch == 'i') {AddCh(); goto case 119;}
                else if (ch == 's') {AddCh(); goto case 121;}
                else {goto case 0;}
            case 191:
                if (ch == 'd') {AddCh(); goto case 192;}
                else {goto case 0;}
            case 192:
                if (ch == 'i') {AddCh(); goto case 123;}
                else if (ch == 'r') {AddCh(); goto case 146;}
                else {goto case 0;}
            case 193:
                {t.kind = 136; break;}
            case 194:
                {t.kind = 141; break;}
            case 195:
                recEnd = pos; recKind = 103;
                if (ch == '-') {AddCh(); goto case 81;}
                else if (ch == '=') {AddCh(); goto case 91;}
                else if (ch == '>') {AddCh(); goto case 194;}
                else {t.kind = 103; break;}
            case 196:
                recEnd = pos; recKind = 139;
                if (ch == '=') {AddCh(); goto case 82;}
                else {t.kind = 139; break;}
            case 197:
                recEnd = pos; recKind = 140;
                if (ch == '=') {AddCh(); goto case 92;}
                else {t.kind = 140; break;}
            case 198:
                recEnd = pos; recKind = 137;
                if (ch == '=') {AddCh(); goto case 95;}
                else if (ch == '|') {AddCh(); goto case 193;}
                else {t.kind = 137; break;}
            case 199:
                recEnd = pos; recKind = 138;
                if (ch == '=') {AddCh(); goto case 103;}
                else {t.kind = 138; break;}

            }
            t.val = new String(tval, 0, tlen);
            return t;
        }
示例#4
0
 // make sure that peeking starts at the current scan position
 public void ResetPeek()
 {
     pt = tokens;
 }
示例#5
0
 // get the next token (possibly a token already seen during peeking)
 public Token Scan()
 {
     if (tokens.next == null) {
     return NextToken();
     } else {
     pt = tokens = tokens.next;
     return tokens;
     }
 }
示例#6
0
        // peek for the next token, ignore pragmas
        public Token Peek()
        {
            do {
            if (pt.next == null) {
                pt.next = NextToken();
            }
            pt = pt.next;
            } while (pt.kind > maxT); // skip pragmas

            return pt;
        }
示例#7
0
 // peek the next token, including pragmas
 public Token PeekWithPragmas()
 {
     if (pt.next == null) {
     pt.next = NextToken();
     }
     pt = pt.next;
     return pt;
 }
示例#8
0
        /* returns the token after the type               *
         * if a type could be recognized, otherwise null. */
        Token IsType(Token pt)
        {
            wasPointerOrArrayType = false;
              if (typeKW[kindInContext(pt.kind)]) {
             pt = PeekWithPragmas();
              } else if (pt.kind == _void) {
             pt = PeekWithPragmas();
             if (pt.kind != _times) {
            return null;
             }
             wasPointerOrArrayType = true;
             pt = PeekWithPragmas();
              } else if (kindInContext(pt.kind) == _ident) {
             pt = PeekWithPragmas();
             if (pt.kind == _dblcolon || pt.kind == _dot) {
            // either namespace alias qualifier "::" or first
            // part of the qualident
            pt = PeekWithPragmas();
            pt = IsQualident(pt);
            if (pt == null) {
              return null;
            }
             }
             if (pt.kind == _lt) {
            pt = IsTypeArgumentList(pt);
            if (pt == null) {
              return null;
            }
            if (pt.kind == _dot) {
              pt = PeekWithPragmas();
              pt = IsType(pt);
              if (pt == null) {
             return null;
              }
            }
             }
              } else {
             return null;
              }
              if (pt.kind == _question) {
             pt = PeekWithPragmas();
              }

              Token prePt = pt;
              pt = SkipPointerOrDims(pt);
              wasPointerOrArrayType |= prePt != pt;

              return pt;
        }
示例#9
0
 /* returns the token after the type argument list *
  * if type argument list could be recognized,     *
  * otherwise null.                                */
 Token IsTypeArgumentList(Token pt)
 {
     if (pt.kind == _lt) {
      pt = PeekWithPragmas();
      while (true) {
     pt = IsType(pt);
     if (pt == null) {
       return null;
     }
     if (pt.kind == _gt) {
       // list recognized
       pt = PeekWithPragmas();
       break;
     } else if (pt.kind == _comma) {
       // another argument
       pt = PeekWithPragmas();
     } else {
       // error in type argument list
       return null;
     }
      }
       } else {
      return null;
       }
       return pt;
 }
示例#10
0
 /* Checks whether the next sequence of tokens is a qualident *
  * and returns the next token after the qualident            *
  * !!! Proceeds from current peek position !!!               */
 Token IsQualident(Token pt)
 {
     if (kindInContext(pt.kind) == _ident) {
       pt = PeekWithPragmas();
       while (pt.kind == _dot) {
         pt = PeekWithPragmas();
         if (kindInContext(pt.kind) != _ident) return null;
         pt = PeekWithPragmas();
       }
       return pt;
      } else return null;
 }
示例#11
0
        void Get()
        {
            for (;;) {
            t = la;
            la = scanner.Scan();
            if (la.kind <= maxT) { switchTokenContext(); ++errDist; break; }
                if (la.kind == 143) {
                AddCCS(la.val);
                }
                if (la.kind == 144) {
                RemCCS(la.val);
                }
                if (la.kind == 145) {
                IfPragma(la.val);
                }
                if (la.kind == 146) {
                ElifOrElsePragma();
                }
                if (la.kind == 147) {
                ElifOrElsePragma();
                }
                if (la.kind == 148) {
                }
                if (la.kind == 149) {
                }
                if (la.kind == 150) {
                }
                if (la.kind == 151) {
                }
                if (la.kind == 152) {
                }
                if (la.kind == 153) {
                }
                if (la.kind == 154) {
                }

            la = t;
            }
        }
示例#12
0
        Token CopyTokens(Token start, Token end)
        {
            Token tokens = Copy(start);

             Token t = tokens;
             while(true) {
             start = start.next;
             if (start == end) break;
             if (start.kind > maxT) continue;
             t = t.next = Copy(start);
             }
            return tokens;
        }
示例#13
0
 Token Copy(Token t)
 {
     Token copy = new Token();
      copy.kind = t.kind;
      copy.pos = t.pos;
      copy.col = t.col;
      copy.line = t.line;
      copy.val = t.val;
      return copy;
 }
示例#14
0
 public void Parse()
 {
     la = new Token();
     la.val = "";
     Get();
     ParseCS3();
     Expect(0); // expect end-of-file automatically added
 }