Esempio n. 1
0
 void Init()
 {
     pos = -1; line = 1; lineStart = 0;
     oldEols = 0;
     NextCh();
     ignore = new BitArray(charSetSize+1);
     ignore[' '] = true;  // blanks are always white space
     ignore[9] = true; ignore[10] = true; ignore[13] = true;
     pt = tokens = new Token();  // first token is a dummy
 }
Esempio n. 2
0
        Token NextToken()
        {
            while (ignore[ch]) NextCh();

            t = new Token();
            t.pos = pos; t.col = pos - lineStart + 1; t.line = line;
            int state = start[ch];
            tlen = 0; AddCh();

            switch (state) {
            case -1: { t.kind = eofSym; break; } // NextCh already done
            case 0: { t.kind = noSym; break; }   // NextCh already done
            case 1:
                {t.kind = 1; break;}
            case 2:
                if ((ch >= '0' && ch <= '9')) {AddCh(); goto case 2;}
                else {t.kind = 2; break;}
            case 3:
                {t.kind = 3; break;}
            case 4:
                {t.kind = 4; break;}

            }
            t.val = new String(tval, 0, tlen);
            return t;
        }
Esempio n. 3
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;
     }
 }
Esempio n. 4
0
 // make sure that peeking starts at the current scan position
 public void ResetPeek()
 {
     pt = tokens;
 }
Esempio n. 5
0
 // peek for the next token, ignore pragmas
 public Token Peek()
 {
     if (pt.next == null) {
     do {
         pt = pt.next = NextToken();
     } while (pt.kind > maxT); // skip pragmas
     } else {
     do {
         pt = pt.next;
     } while (pt.kind > maxT);
     }
     return pt;
 }
Esempio n. 6
0
        void Get()
        {
            for (;;) {
            token = la;
            la = scanner.Scan();
            if (la.kind <= maxT) { ++errDist; break; }

            la = token;
            }
        }
Esempio n. 7
0
        public IDice Parse()
        {
            la = new Token();
            la.val = "";
            Get();
            Dice();

            Expect(0);
            return dice;
        }