internal ScannerEnumerator(Scanner scanner, ILogging logging) { this.scanner = scanner; this.document = scanner.document; this.textSource = scanner.textSource; this.termFactory = scanner.scanAction; this.logging = logging; this.cursor = new ScanCursor { RootContext = scanner.context, CurrentMode = scanner.startMode, Buffer = new char[Scanner.BufferSize], Cursor = 0, Limit = 0, Marker = -1, Start = 0, InnerState = 0, Actions = new int[scanner.MaxActionCount], ActionCount = 0, }; cursor.Buffer[0] = Scanner.Sentinel; this.priorPosition = 0; this.priorLine = 1; this.priorColumn = 1; InitContext(); }
public void Dispose() { this.cursor = null; }
private int Scan1(ScanCursor cursor) { char ch; switch (cursor.InnerState) { case 0: goto M0; case 1: goto MDIGIT; case 2: goto MSPACE; default: goto L0; } FIN: return 0; L0: // State #0 M0: ch = cursor.Buffer[cursor.Cursor]; if (ch == Scanner.Sentinel) { if (cursor.Limit == cursor.Cursor) { cursor.InnerState = 0; return 1; } // Non accept goto FIN; } else if (ch == ' ') { goto LSPACE; } else if (char.IsDigit(ch)) { goto LDIGIT; } else { goto FIN; } LDIGIT: // State #1 ++cursor.Cursor; cursor.ActionCount = 1; cursor.EnvelopeId = 1; cursor.Actions[0] = 1; cursor.Marker = cursor.Cursor; // accept MDIGIT: ch = cursor.Buffer[cursor.Cursor]; if (ch == Scanner.Sentinel) { if (cursor.Limit == cursor.Cursor) { cursor.InnerState = 1; return 1; } // Non accept goto FIN; } else if (char.IsDigit(ch)) { goto LDIGIT; } else { goto FIN; } LSPACE: // State #2 ++cursor.Cursor; cursor.ActionCount = 1; cursor.Actions[0] = 0; cursor.EnvelopeId = 0; cursor.Marker = cursor.Cursor; MSPACE: ch = cursor.Buffer[cursor.Cursor]; if (ch == Scanner.Sentinel) { if (cursor.Limit == cursor.Cursor) { cursor.InnerState = 2; return 1; } goto FIN; } else if (ch == ' ') { goto LSPACE; } else { goto FIN; } }