/source/library/Interlace.Pinch/Interlace.Pinch/Parsing/PinchLexer.cs
C# | 1438 lines | 1199 code | 102 blank | 137 comment | 137 complexity | 57f4f68698db59afe8628f404c97782a MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- //
- // This CSharp output file generated by Gardens Point LEX
- // Version: 0.6.2.196 (2007-11-13)
- // Machine: FOURIER
- // DateTime: 11/01/2012 5:48:56 PM
- // UserName: Administrator
- // GPLEX input file <PinchLexer.l>
- // GPLEX frame file <C:\Development\gplex\binaries\gplexx.frame>
- //
- // Option settings: parser, minimize, compressnext
- //
-
- //
- // gplexx.frame
- // Version 0.6.2 of 13-November-2007
- // Derived from gplex.frame version of 2-September-2006.
- // Left and Right Anchored state support.
- // Start condition stack. Two generic params.
- // Using fixed length context handling for right anchors
- //
- using System;
- using System.IO;
- using System.Collections.Generic;
- #if !STANDALONE
- using gppg;
- #endif
-
- using System.Text;
-
- namespace Interlace.Pinch.Parsing
- {
- /// <summary>
- /// Summary Canonical example of GPLEX automaton
- /// </summary>
-
- #if STANDALONE
- //
- // These are the dummy declarations for stand-alone GPLEX applications
- // normally these declarations would come from the parser.
- // If you declare /noparser, or %option noparser then you get this.
- //
-
- public enum Tokens
- {
- EOF = 0, maxParseToken = int.MaxValue
- // must have at least these two, values are almost arbitrary
- }
-
- public abstract class ScanBase
- {
- public abstract int yylex();
- #if BABEL
- protected abstract int CurrentSc { get; set; }
- // EolState is the 32-bit of state data persisted at
- // the end of each line for Visual Studio colorization.
- // The default is to return CurrentSc. You must override
- // this if you want more complicated behavior.
- public virtual int EolState {
- get { return CurrentSc; }
- set { CurrentSc = value; }
- }
- }
-
- public interface IColorScan
- {
- void SetSource(string source, int offset);
- int GetNext(ref int state, out int start, out int end);
- #endif // BABEL
- }
-
- #endif // STANDALONE
-
- public abstract class ScanBuff
- {
- public const int EOF = -1;
- public abstract int Pos { get; set; }
- public abstract int Read();
- public abstract int Peek();
- public abstract int ReadPos { get; }
- public abstract string GetString(int b, int e);
- }
-
- // If the compiler can't find ScanBase maybe you need to run
- // GPPG with the /gplex option, or GPLEX with /noparser
- #if BABEL
- public sealed partial class Scanner : ScanBase, IColorScan
- {
- public ScanBuff buffer;
- int currentScOrd; // start condition ordinal
-
- protected override int CurrentSc
- {
- // The current start state is a property
- // to try to avoid the user error of setting
- // scState but forgetting to update the FSA
- // start state "currentStart"
- //
- get { return currentScOrd; } // i.e. return YY_START;
- set { currentScOrd = value; // i.e. BEGIN(value);
- currentStart = startState[value]; }
- }
- #else // BABEL
- public sealed partial class Scanner : ScanBase
- {
- public ScanBuff buffer;
- int currentScOrd; // start condition ordinal
- #endif // BABEL
-
- private static int GetMaxParseToken() {
- System.Reflection.FieldInfo f = typeof(Tokens).GetField("maxParseToken");
- return (f == null ? int.MaxValue : (int)f.GetValue(null));
- }
-
- static int parserMax = GetMaxParseToken();
-
- enum Result {accept, noMatch, contextFound};
-
- const int maxAccept = 77;
- const int initial = 78;
- const int eofNum = 0;
- const int goStart = -1;
- const int INITIAL = 0;
-
- int state;
- int currentStart = initial;
- int chr; // last character read
- int cNum = 0; // ordinal number of chr
- int lNum = 0; // current line number
- int lineStartNum; // ordinal number at start of line
- //
- // The following instance variables are used, among other
- // things, for constructing the yylloc location objects.
- //
- int tokPos; // buffer position at start of token
- int tokNum; // ordinal number of first character
- int tokLen; // number of characters in token
- int tokCol; // zero-based column number at start of token
- int tokLin; // line number at start of token
- int tokEPos; // buffer position at end of token
- int tokECol; // column number at end of token
- int tokELin; // line number at end of token
- string tokTxt; // lazily constructed text of token
- #if STACK
- private Stack<int> scStack = new Stack<int>();
- #endif // STACK
-
- #region ScannerTables
- struct Table {
- public int min; public int rng; public int dflt;
- public sbyte[] nxt;
- public Table(int m, int x, int d, sbyte[] n) {
- min = m; rng = x; dflt = d; nxt = n;
- }
- };
-
- static int[] startState = {78, 0};
-
- static Table[] NxS = new Table[79];
-
- static Scanner() {
- NxS[0] = new Table(0, 0, 0, null); NxS[1] = new Table(0, 0, -1, null); NxS[2] = new Table(9, 24, -1, new sbyte[] {2, 2, -1, -1, 2, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 2});
- NxS[3] = new Table(0, 0, -1, null); NxS[4] = new Table(0, 0, -1, null); NxS[5] = new Table(0, 0, -1, null); NxS[6] = new Table(0, 0, -1, null); NxS[7] = new Table(48, 10, -1, new sbyte[] {7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7});
- NxS[8] = new Table(0, 0, -1, null); NxS[9] = new Table(0, 0, -1, null); NxS[10] = new Table(0, 0, -1, null); NxS[11] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[12] = new Table(0, 0, -1, null); NxS[13] = new Table(0, 0, -1, null); NxS[14] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 73, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[15] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 63, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[16] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 57,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[17] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 50, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[18] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 43, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[19] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 31,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[20] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 23, 11,
- 11, 11, 11, 11, 11});
- NxS[21] = new Table(0, 0, -1, null); NxS[22] = new Table(0, 0, -1, null); NxS[23] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 24, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[24] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 25,
- 11, 11, 11, 11, 11});
- NxS[25] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 26, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[26] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 27, 11,
- 11, 11, 11, 11, 11});
- NxS[27] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 28,
- 11, 11, 11, 11, 11});
- NxS[28] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 29, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[29] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 30,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[30] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[31] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 32, 11, 11, 11, 33, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[32] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 39, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[33] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 34,
- 11, 11, 11, 11, 11});
- NxS[34] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 35, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[35] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 36, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[36] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 37,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[37] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 38, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[38] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[39] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 40, 11, 11, 11, 11});
- NxS[40] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 41,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[41] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 42, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[42] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[43] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 44, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[44] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 45, 11,
- 11, 11, 11, 11, 11});
- NxS[45] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 46, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[46] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 47, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[47] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 48, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[48] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 49, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[49] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[50] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 51, 11,
- 11, 11, 11, 11, 11});
- NxS[51] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 52, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[52] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 53, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[53] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 54, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[54] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 55, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[55] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 56, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[56] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[57] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 58, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[58] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 59, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[59] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 60, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[60] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 61, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[61] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 62,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[62] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[63] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 64,
- 11, 11, 11, 11, 11});
- NxS[64] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 65, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[65] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 66,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[66] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 67, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[67] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 68, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[68] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 69, 11,
- 11, 11, 11, 11, 11});
- NxS[69] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 70, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[70] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 71, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[71] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 72, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[72] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[73] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 74, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[74] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 75, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[75] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 76, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[76] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 77,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[77] = new Table(48, 75, -1, new sbyte[] {11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, -1, -1, -1, -1, 11, -1, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11});
- NxS[78] = new Table(9, 117, 1, new sbyte[] {2, 2, 1, 1, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 4, 1, 1, 5, 1, 6,
- 1, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 8, 9, 1, 10,
- 1, 1, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 1, 13, 1,
- 11, 1, 11, 11, 14, 11, 15, 11, 11, 11, 11, 11, 11, 11, 16, 11,
- 17, 18, 11, 19, 20, 11, 11, 11, 11, 11, 11, 11, 21, 1, 22});
- }
-
- int NextState(int qStat) {
- if (chr == ScanBuff.EOF)
- return (qStat <= maxAccept && qStat != currentStart ? currentStart : eofNum);
- else {
- int rslt;
- int idx = (byte)(chr - NxS[qStat].min);
- if ((uint)idx >= (uint)NxS[qStat].rng) rslt = NxS[qStat].dflt;
- else rslt = NxS[qStat].nxt[idx];
- return (rslt == goStart ? currentStart : rslt);
- }
- }
-
- int NextState() {
- if (chr == ScanBuff.EOF)
- return (state <= maxAccept && state != currentStart ? currentStart : eofNum);
- else {
- int rslt;
- int idx = (byte)(chr - NxS[state].min);
- if ((uint)idx >= (uint)NxS[state].rng) rslt = NxS[state].dflt;
- else rslt = NxS[state].nxt[idx];
- return (rslt == goStart ? currentStart : rslt);
- }
- }
- #endregion
-
-
- #if BACKUP
- // ====================== Nested class ==========================
-
- internal class Context // class used for automaton backup.
- {
- public int bPos;
- public int cNum;
- public int state;
- public int cChr;
- }
- #endif // BACKUP
-
- // ==============================================================
- // ===== Nested classes for various ScanBuff derived classes ====
- // ==============================================================
-
- public sealed class StringBuff : ScanBuff
- {
- string str; // input buffer
- int bPos; // current position in buffer
- int sLen;
-
- public StringBuff(string str)
- {
- this.str = str;
- this.sLen = str.Length;
- }
-
- public override int Read()
- {
- if (bPos < sLen) return str[bPos++];
- #if BABEL
- else if (bPos == sLen) { bPos++; return '\n'; } // one strike, see newline
- #endif // BABEL
- else { bPos++; return EOF; } // two strikes and you're out!
- }
-
- public override int ReadPos { get { return bPos - 1; } }
-
- public override int Peek()
- {
- if (bPos < sLen) return str[bPos];
- else return '\n';
- }
-
- public override string GetString(int beg, int end)
- {
- // "end" can be greater than sLen with the BABEL
- // option set. Read returns a "virtual" EOL if
- // an attempt is made to read past the end of the
- // string buffer. Without the guard any attempt
- // to fetch yytext for a token that includes the
- // EOL will throw an index exception.
- if (end > sLen) end = sLen;
- if (end <= beg) return "";
- else return str.Substring(beg, end - beg);
- }
-
- public override int Pos
- {
- get { return bPos; }
- set { bPos = value; }
- }
- }
-
- // ====================== Nested class ==========================
- // The LineBuff class contributed by Nigel Horspool,
- // nigelh@cs.uvic.cs
- // ==============================================================
-
- public sealed class LineBuff : ScanBuff
- {
- IList<string> line; // list of source lines from a file
- int numLines; // number of strings in line list
- string curLine; // current line in that list
- int cLine; // index of current line in the list
- int curLen; // length of current line
- int curLineStart; // position of line start in whole file
- int curLineEnd; // position of line end in whole file
- int maxPos; // max position ever visited in whole file
- int cPos; // ordinal number of chr in source
-
- // Constructed from a list of strings, one per source line.
- // The lines have had trailing '\n' characters removed.
- public LineBuff(IList<string> lineList)
- {
- line = lineList;
- numLines = line.Count;
- cPos = curLineStart = 0;
- curLine = numLines>0? line[0] : "";
- maxPos = curLineEnd = curLen = curLine.Length;
- cLine = 1;
- }
-
- public override int Read()
- {
- if (cPos < curLineEnd)
- return curLine[cPos++ - curLineStart];
- if (cPos++ == curLineEnd)
- return '\n';
- if (cLine >= numLines)
- return EOF;
- curLine = line[cLine];
- curLen = curLine.Length;
- curLineStart = curLineEnd + 1;
- curLineEnd = curLineStart + curLen;
- if (curLineEnd>maxPos)
- maxPos = curLineEnd;
- cLine++;
- return curLen>0? curLine[0] : '\n';
- }
-
- public override int Peek()
- {
- return (cPos < curLineEnd)? curLine[cPos - curLineStart] : '\n';
- }
-
- // To speed up searches for the line containing a position
- private int cachedPos = 0;
- private int cachedIx = 0;
- private int cachedLstart = 0;
-
- // Given a position pos within the entire source, the results are
- // ix -- the index of the containing line
- // lstart -- the position of the first character on that line
- private void findIndex( int pos, out int ix, out int lstart )
- {
- if (pos >= cachedPos) {
- ix = cachedIx; lstart = cachedLstart;
- } else {
- ix = lstart = 0;
- }
- for( ; ; ) {
- int len = line[ix].Length + 1;
- if (pos < lstart+len) break;
- lstart += len;
- ix++;
- }
- cachedPos = pos;
- cachedIx = ix;
- cachedLstart = lstart;
- }
-
- public override string GetString(int beg, int end)
- {
- if (beg >= maxPos || end <= beg) return "";
- int endIx, begIx, endLineStart, begLineStart;
- findIndex(beg, out begIx, out begLineStart);
- int begCol = beg - begLineStart;
- findIndex(end, out endIx, out endLineStart);
- int endCol = end - endLineStart;
- string s = line[begIx];
- if (begIx == endIx) {
- // the usual case, substring all on one line
- return (endCol <= s.Length)?
- s.Substring(begCol, endCol-begCol)
- : s.Substring(begCol) + "\n";
- }
- // the string spans multiple lines, yuk!
- StringBuilder sb = new StringBuilder();
- if (begCol < s.Length)
- sb.Append(s.Substring(begCol));
- for( ; ; ) {
- sb.Append("\n");
- s = line[++begIx];
- if (begIx >= endIx) break;
- sb.Append(s);
- }
- if (endCol <= s.Length) {
- sb.Append(s.Substring(0, endCol));
- } else {
- sb.Append(s);
- sb.Append("\n");
- }
- return sb.ToString();
- }
-
- public override int Pos
- {
- get { return cPos; }
- set {
- cPos = value;
- findIndex(cPos, out cLine, out curLineStart);
- curLine = line[cLine];
- curLineEnd = curLineStart+curLine.Length;
- }
- }
-
- public override int ReadPos { get { return cPos - 1; } }
- }
-
- // ====================== Nested class ==========================
-
- public sealed class StreamBuff : ScanBuff
- {
- BufferedStream bStrm; // input buffer
- int delta = 1; // number of bytes in chr, could be 0 for EOF.
-
- public StreamBuff(Stream str) { this.bStrm = new BufferedStream(str); }
-
- public override int Read() {
- int ch0 = bStrm.ReadByte();
- delta = (ch0 == EOF ? 0 : 1);
- return ch0;
- }
-
- public override int ReadPos {
- get { return (int)bStrm.Position - delta; }
- }
-
- public override int Peek()
- {
- int rslt = bStrm.ReadByte();
- bStrm.Seek(-delta, SeekOrigin.Current);
- return rslt;
- }
-
- public override string GetString(int beg, int end)
- {
- if (end - beg <= 0) return "";
- long savePos = bStrm.Position;
- char[] arr = new char[end - beg];
- bStrm.Position = (long)beg;
- for (int i = 0; i < (end - beg); i++)
- arr[i] = (char)bStrm.ReadByte();
- bStrm.Position = savePos;
- return new String(arr);
- }
-
- // Pos is the position *after* reading chr!
- public override int Pos
- {
- get { return (int)bStrm.Position; }
- set { bStrm.Position = value; }
- }
- }
-
- // ====================== Nested class ==========================
-
- /// <summary>
- /// This is the Buffer for UTF8 files.
- /// It attempts to read the encoding preamble, which for
- /// this encoding should be unicode point \uFEFF which is
- /// encoded as EF BB BF
- /// </summary>
- public class TextBuff : ScanBuff
- {
- protected BufferedStream bStrm; // input buffer
- protected int delta = 1; // length of chr, zero for EOF!
-
- private Exception BadUTF8()
- { return new Exception(String.Format("BadUTF8 Character")); }
-
- /// <summary>
- /// TextBuff factory. Reads the file preamble
- /// and returns a TextBuff, LittleEndTextBuff or
- /// BigEndTextBuff according to the result.
- /// </summary>
- /// <param name="strm">The underlying stream</param>
- /// <returns></returns>
- public static TextBuff NewTextBuff(Stream strm)
- {
- // First check if this is a UTF16 file
- //
- int b0 = strm.ReadByte();
- int b1 = strm.ReadByte();
-
- if (b0 == 0xfe && b1 == 0xff)
- return new BigEndTextBuff(strm);
- if (b0 == 0xff && b1 == 0xfe)
- return new LittleEndTextBuff(strm);
-
- int b2 = strm.ReadByte();
- if (b0 == 0xef && b1 == 0xbb && b2 == 0xbf)
- return new TextBuff(strm);
- //
- // There is no unicode preamble, so we
- // must go back to the UTF8 default.
- //
- strm.Seek(0, SeekOrigin.Begin);
- return new TextBuff(strm);
- }
-
- protected TextBuff(Stream str) {
- this.bStrm = new BufferedStream(str);
- }
-
- public override int Read()
- {
- int ch0 = bStrm.ReadByte();
- int ch1;
- int ch2;
- if (ch0 < 0x7f)
- {
- delta = (ch0 == EOF ? 0 : 1);
- return ch0;
- }
- else if ((ch0 & 0xe0) == 0xc0)
- {
- delta = 2;
- ch1 = bStrm.ReadByte();
- if ((ch1 & 0xc0) == 0x80)
- return ((ch0 & 0x1f) << 6) + (ch1 & 0x3f);
- else
- throw BadUTF8();
- }
- else if ((ch0 & 0xf0) == 0xe0)
- {
- delta = 3;
- ch1 = bStrm.ReadByte();
- ch2 = bStrm.ReadByte();
- if ((ch1 & ch2 & 0xc0) == 0x80)
- return ((ch0 & 0xf) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f);
- else
- throw BadUTF8();
- }
- else
- throw BadUTF8();
- }
-
- public sealed override int ReadPos
- {
- get { return (int)bStrm.Position - delta; }
- }
-
- public sealed override int Peek()
- {
- int rslt = Read();
- bStrm.Seek(-delta, SeekOrigin.Current);
- return rslt;
- }
-
- /// <summary>
- /// Returns the string from the buffer between
- /// the given file positions. This needs to be
- /// done carefully, as the number of characters
- /// is, in general, not equal to (end - beg).
- /// </summary>
- /// <param name="beg">Begin filepos</param>
- /// <param name="end">End filepos</param>
- /// <returns></returns>
- public sealed override string GetString(int beg, int end)
- {
- int i;
- if (end - beg <= 0) return "";
- long savePos = bStrm.Position;
- char[] arr = new char[end - beg];
- bStrm.Position = (long)beg;
- for (i = 0; bStrm.Position < end; i++)
- arr[i] = (char)Read();
- bStrm.Position = savePos;
- return new String(arr, 0, i);
- }
-
- // Pos is the position *after* reading chr!
- public sealed override int Pos
- {
- get { return (int)bStrm.Position; }
- set { bStrm.Position = value; }
- }
- }
-
- // ====================== Nested class ==========================
- /// <summary>
- /// This is the Buffer for Big-endian UTF16 files.
- /// </summary>
- public sealed class BigEndTextBuff : TextBuff
- {
- internal BigEndTextBuff(Stream str) : base(str) { } //
-
- public override int Read()
- {
- int ch0 = bStrm.ReadByte();
- int ch1 = bStrm.ReadByte();
- if (ch1 == EOF)
- {
- // An EOF in either byte counts as an EOF
- delta = (ch0 == EOF ? 0 : 1);
- return -1;
- }
- else
- {
- delta = 2;
- return (ch0 << 8) + ch1;
- }
- }
- }
-
- // ====================== Nested class ==========================
- /// <summary>
- /// This is the Buffer for Little-endian UTF16 files.
- /// </summary>
- public sealed class LittleEndTextBuff : TextBuff
- {
- internal LittleEndTextBuff(Stream str) : base(str) { } // { this.bStrm = new BufferedStream(str); }
-
- public override int Read()
- {
- int ch0 = bStrm.ReadByte();
- int ch1 = bStrm.ReadByte();
- if (ch1 == EOF)
- {
- // An EOF in either byte counts as an EOF
- delta = (ch0 == EOF ? 0 : 1);
- return -1;
- }
- else
- {
- delta = 2;
- return (ch1 << 8) + ch1;
- }
- }
- }
- // =================== End Nested classes =======================
-
- public Scanner(Stream file) {
- buffer = new StreamBuff(file);
- this.cNum = -1;
- this.chr = '\n'; // to initialize yyline, yycol and lineStart
- GetChr();
- }
-
- public Scanner() { }
-
- void GetChr()
- {
- if (chr == '\n')
- {
- lineStartNum = cNum + 1;
- lNum++;
- }
- chr = buffer.Read();
- cNum++;
- }
-
- void MarkToken()
- {
- tokPos = buffer.ReadPos;
- tokNum = cNum;
- tokLin = lNum;
- tokCol = cNum - lineStartNum;
- }
-
- void MarkEnd()
- {
- tokTxt = null;
- tokLen = cNum - tokNum;
- tokEPos = buffer.ReadPos;
- tokELin = lNum;
- tokECol = cNum - lineStartNum;
- }
-
- // ===================================================…
Large files files are truncated, but you can click here to view the full file