void AddCh() { if (tlen >= tval.length) { char[] newBuf = new char[2 * tval.length]; System.arraycopy(tval, 0, newBuf, 0, tval.length); tval = newBuf; } if (ch != Buffer.EOF) { tval[tlen++] = (char)ch; NextCh(); } }
public Token Scan() { if (tokens.next == null) { return NextToken(); } else { pt = tokens = tokens.next; return tokens; } }
void Get() { for (;;) { t = la; la = scanner.Scan(); if (la.kind <= maxT) { ++errDist; break; } la = t; } }
Token NextToken() { while (ch == ' ' || false ) NextCh(); int state = start.state(ch); tlen = 0; AddCh(); if (recKind != noSym) { tlen = recEnd - t.pos; SetScannerBehindT(); if (ch == '$' || ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); state = 1; break;} else {t.kind = 1; break loop;} case 2: recEnd = pos; recKind = 2; if (ch >= '0' && ch <= '7') {AddCh(); state = 5; break;} else if (ch == 'x') {AddCh(); state = 3; break;} else if (ch == 'b') {AddCh(); state = 4; break;} else {t.kind = 2; break loop;} case 3: recEnd = pos; recKind = 2; if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); state = 3; break;} else {t.kind = 2; break loop;} case 4: recEnd = pos; recKind = 2; if (ch >= '0' && ch <= '1') {AddCh(); state = 4; break;} else {t.kind = 2; break loop;} case 5:
public Scanner(InputStream s) { buffer = new Buffer(s); Init(); }
public Parser(InputStream input) { this.scanner = new Scanner(input); errors = new Errors(); }
Token NextToken() { while (ch == ' ' || false ) NextCh(); int state = start.state(ch); tlen = 0; AddCh(); if (recKind != noSym) { tlen = recEnd - t.pos; SetScannerBehindT(); if (ch == '$' || ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); state = 1; break;} else {t.kind = 1; break loop;} case 2: recEnd = pos; recKind = 2; if (ch >= '0' && ch <= '7') {AddCh(); state = 5; break;} else if (ch == 'x') {AddCh(); state = 3; break;} else if (ch == 'b') {AddCh(); state = 4; break;} else {t.kind = 2; break loop;} case 3: recEnd = pos; recKind = 2; if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); state = 3; break;} else {t.kind = 2; break loop;} case 4: recEnd = pos; recKind = 2; if (ch >= '0' && ch <= '1') {AddCh(); state = 4; break;} else {t.kind = 2; break loop;} case 5:
public Scanner(String fileName) { buffer = new Buffer(fileName); Init(); }
public Parser(InputStream input) { this.scanner = new Scanner(input); errors = new Errors(); }
void AddCh() { if (tlen >= tval.length) { char[] newBuf = new char[2 * tval.length]; System.arraycopy(tval, 0, newBuf, 0, tval.length); tval = newBuf; } if (ch != Buffer.EOF) { tval[tlen++] = (char)ch; NextCh(); } }
public Token Peek() { do { if (pt.next == null) { pt.next = NextToken(); } pt = pt.next; } while (pt.kind > maxT); // skip pragmas return pt; }
public Scanner(String fileName) { buffer = new Buffer(fileName); Init(); }
void Get() { for (;;) { t = la; la = scanner.Scan(); if (la.kind <= maxT) { ++errDist; break; } la = t; } }
public Token Scan() { if (tokens.next == null) { return NextToken(); } else { pt = tokens = tokens.next; return tokens; } }
public Scanner(InputStream s) { buffer = new Buffer(s); Init(); }
public Token Peek() { do { if (pt.next == null) { pt.next = NextToken(); } pt = pt.next; } while (pt.kind > maxT); // skip pragmas return pt; }
void Init() { pos = -1; line = 1; col = 0; charPos = -1; 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("Illegal byte order mark at start of file"); } buffer = new UTF8Buffer(buffer); col = 0; charPos = -1; NextCh(); } pt = tokens = new Token(); // first token is a dummy }
void Init() { pos = -1; line = 1; col = 0; charPos = -1; 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("Illegal byte order mark at start of file"); } buffer = new UTF8Buffer(buffer); col = 0; charPos = -1; NextCh(); } pt = tokens = new Token(); // first token is a dummy }