Scanner.cs :  » Profilers » Prof-It » at » jku » ssw » ProfIt » Coco » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Profilers » Prof It 
Prof It » at » jku » ssw » ProfIt » Coco » Scanner.cs

using System;
using System.IO;
using System.Collections;
using System.Text;

namespace at.jku.ssw.ProfIt.Coco{

public class Token {
  public int kind;    // token kind
  public int pos;     // token position in the source text (starting at 0)
  public int col;     // token column (starting at 0)
  public int line;    // token line (starting at 1)
  public string val;  // token value
  public Token next;  // AW 2003-03-07 Tokens are kept in linked list
}

public class Buffer {
  static byte[] buf;
  static int bufLen;
  static int pos;
  
  public static void Fill (Stream s) {
    bufLen = (int) s.Length;
    buf = new byte[bufLen];
    s.Read(buf, 0, bufLen); 
    pos = 0;
  }
  
  public static int Read () {
    if (pos < bufLen) return buf[pos++];
    else return 0;
  }

  public static int Peek () {
    if (pos < bufLen) return buf[pos];
    else return 0;
  }
  
  /* AW 2003-03-10 moved this from ParserGen.cs */
  public static string GetString (int beg, int end) {
    StringBuilder s = new StringBuilder(64);
    int oldPos = Buffer.Pos;
    Buffer.Pos = beg;
    while (beg < end) { s.Append((char)Buffer.Read()); beg++; }
    Buffer.Pos = oldPos;
    return s.ToString();
  }

  public static int Pos {
    get { return pos; }
    set {
      if (value < 0) pos = 0; 
      else if (value >= bufLen) pos = bufLen; 
      else pos = value;
    }
  }
}

public class Scanner {
  const char EOF = '\0';
  const char EOL = '\n';
  const int charSetSize = 256;
  const int maxT = 128;
  const int noSym = 128;
  static short[] start = {
  178,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0, 64, 36,131,  0,157, 53, 19, 63, 67, 70, 59, 56, 57,  6,155,
  130,128,128,128,128,128,128,128,128,128, 55, 68,164, 54,167,170,
  129,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
    1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1, 62,  0, 66,162,  1,
    0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
    1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1, 61,160, 65, 69,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  0,  0,  1,
    0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  0,  0,  0,
    0};


  static Token t;          // current token
  static char ch;          // current input character
  static int pos;          // column number of current character
  static int line;         // line number of current character
  static int lineStart;    // start position of current line
  static int oldEols;      // EOLs that appeared in a comment;
  static BitArray ignore;  // set of characters to be ignored by the scanner

  static Token tokens;     // the complete input token stream
  static Token pt;         // current peek token
  
  public static void Init (string fileName) {
    FileStream s = null;
    try {
      s = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
      Init(s);
    } catch (IOException) {
      Console.WriteLine("--- Cannot open file {0}", fileName);
      System.Environment.Exit(0);
    } finally {
      if (s != null) s.Close();
    }
  }
  
  public static void Init (Stream s) {
    Buffer.Fill(s);
    pos = -1; line = 1; lineStart = 0;
    oldEols = 0;
    NextCh();
    ignore = new BitArray(charSetSize);
    ignore[9] = true; ignore[10] = true; ignore[13] = true; ignore[32] = true; 
    
    //--- AW: fill token list
    tokens = new Token();  // first token is a dummy
    Token node = tokens;
    do {
      node.next = NextToken();
      node = node.next;
    } while (node.kind != 0);  /* AW: 0 == EOF */
    node.next = node;
    t = pt = tokens;
  }
  
  static void NextCh() {
    if (oldEols > 0) { ch = EOL; oldEols--; } 
    else {
      ch = (char)Buffer.Read(); pos++;
      // replace isolated '\r' by '\n' in order to make
      // eol handling uniform across Windows, Unix and Mac
      if (ch == '\r' && Buffer.Peek() != '\n') ch = EOL;
      if (ch == EOL) { line++; lineStart = pos + 1; }
    }
  }
  

  static bool Comment0() {
    int level = 1, line0 = line, lineStart0 = lineStart;
    NextCh();
    if (ch == '/') {
      NextCh();
      for(;;) {
        if (ch == 10) {
          level--;
          if (level == 0) { oldEols = line - line0; NextCh(); return true; }
          NextCh();
        } else if (ch == EOF) return false;
        else NextCh();
      }
    } else {
      if (ch==EOL) {line--; lineStart = lineStart0;}
      pos = pos - 2; Buffer.Pos = pos+1; NextCh();
    }
    return false;
  }

  static bool Comment1() {
    int level = 1, line0 = line, lineStart0 = lineStart;
    NextCh();
    if (ch == '*') {
      NextCh();
      for(;;) {
        if (ch == '*') {
          NextCh();
          if (ch == '/') {
            level--;
            if (level == 0) { oldEols = line - line0; NextCh(); return true; }
            NextCh();
          }
        } else if (ch == EOF) return false;
        else NextCh();
      }
    } else {
      if (ch==EOL) {line--; lineStart = lineStart0;}
      pos = pos - 2; Buffer.Pos = pos+1; NextCh();
    }
    return false;
  }

  
  static void CheckLiteral() {
    switch (t.val) {
      case "base": t.kind = 6; break;
      case "bool": t.kind = 7; break;
      case "byte": t.kind = 8; break;
      case "char": t.kind = 9; break;
      case "checked": t.kind = 10; break;
      case "decimal": t.kind = 11; break;
      case "double": t.kind = 12; break;
      case "event": t.kind = 13; break;
      case "false": t.kind = 14; break;
      case "float": t.kind = 15; break;
      case "int": t.kind = 16; break;
      case "long": t.kind = 17; break;
      case "new": t.kind = 18; break;
      case "null": t.kind = 19; break;
      case "object": t.kind = 20; break;
      case "return": t.kind = 21; break;
      case "sbyte": t.kind = 22; break;
      case "short": t.kind = 23; break;
      case "sizeof": t.kind = 24; break;
      case "string": t.kind = 25; break;
      case "this": t.kind = 26; break;
      case "true": t.kind = 27; break;
      case "typeof": t.kind = 28; break;
      case "uint": t.kind = 29; break;
      case "ulong": t.kind = 30; break;
      case "unchecked": t.kind = 31; break;
      case "ushort": t.kind = 32; break;
      case "void": t.kind = 33; break;
      case "using": t.kind = 53; break;
      case "namespace": t.kind = 54; break;
      case "class": t.kind = 55; break;
      case "struct": t.kind = 56; break;
      case "interface": t.kind = 57; break;
      case "enum": t.kind = 58; break;
      case "delegate": t.kind = 59; break;
      case "const": t.kind = 60; break;
      case "implicit": t.kind = 61; break;
      case "explicit": t.kind = 62; break;
      case "operator": t.kind = 63; break;
      case "stackalloc": t.kind = 64; break;
      case "ref": t.kind = 65; break;
      case "out": t.kind = 66; break;
      case "params": t.kind = 67; break;
      case "public": t.kind = 68; break;
      case "protected": t.kind = 69; break;
      case "internal": t.kind = 70; break;
      case "private": t.kind = 71; break;
      case "unsafe": t.kind = 72; break;
      case "abstract": t.kind = 73; break;
      case "sealed": t.kind = 74; break;
      case "extern": t.kind = 75; break;
      case "override": t.kind = 76; break;
      case "readonly": t.kind = 77; break;
      case "static": t.kind = 78; break;
      case "virtual": t.kind = 79; break;
      case "volatile": t.kind = 80; break;
      case "if": t.kind = 81; break;
      case "else": t.kind = 82; break;
      case "switch": t.kind = 83; break;
      case "while": t.kind = 84; break;
      case "do": t.kind = 85; break;
      case "for": t.kind = 86; break;
      case "foreach": t.kind = 87; break;
      case "in": t.kind = 88; break;
      case "break": t.kind = 89; break;
      case "continue": t.kind = 90; break;
      case "throw": t.kind = 91; break;
      case "lock": t.kind = 92; break;
      case "fixed": t.kind = 93; break;
      case "case": t.kind = 104; break;
      case "default": t.kind = 105; break;
      case "goto": t.kind = 106; break;
      case "try": t.kind = 107; break;
      case "finally": t.kind = 108; break;
      case "catch": t.kind = 109; break;
      case "is": t.kind = 121; break;
      case "as": t.kind = 122; break;
      default: break;
    }
  }

  /* AW Scan() renamed to NextToken() */
  static Token NextToken() {
    while (ignore[ch]) NextCh();
    if (ch == '/' && Comment0() ||ch == '/' && Comment1()) return NextToken();    int apx = 0;

    t = new Token();
    t.pos = pos; t.col = pos - lineStart + 1; t.line = line; 
    int state = start[ch];
    StringBuilder buf = new StringBuilder(16);
    buf.Append(ch); NextCh();
    
    switch (state) {
      case 0: { t.kind = noSym; goto done; }  // NextCh already done
      case 1:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z' || ch == 196 || ch == 214 || ch == 220 || ch == 223 || ch == 228 || ch == 246 || ch == 252)) {buf.Append(ch); NextCh(); goto case 1;}
        else {t.kind = 1; t.val = buf.ToString(); CheckLiteral(); return t;}
      case 2:
        if ((ch >= '0' && ch <= '9')) {apx = 0; buf.Append(ch); NextCh(); goto case 2;}
        else if (ch == 'U') {apx = 0; buf.Append(ch); NextCh(); goto case 132;}
        else if (ch == 'u') {apx = 0; buf.Append(ch); NextCh(); goto case 133;}
        else if (ch == 'L') {apx = 0; buf.Append(ch); NextCh(); goto case 134;}
        else if (ch == 'l') {apx = 0; buf.Append(ch); NextCh(); goto case 135;}
        else {
          buf.Length = buf.Length - apx;
          pos = pos - apx - 1; line = t.line;
          Buffer.Pos = pos+1; NextCh();
          t.kind = 2; goto done;}
      case 3:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 4;}
        else {t.kind = noSym; goto done;}
      case 4:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 4;}
        else if (ch == 'U') {buf.Append(ch); NextCh(); goto case 136;}
        else if (ch == 'u') {buf.Append(ch); NextCh(); goto case 137;}
        else if (ch == 'L') {buf.Append(ch); NextCh(); goto case 138;}
        else if (ch == 'l') {buf.Append(ch); NextCh(); goto case 139;}
        else {t.kind = 2; goto done;}
      case 5:
        {t.kind = 2; goto done;}
      case 6:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 7;}
        else {t.kind = 39; goto done;}
      case 7:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 7;}
        else if ((ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm')) {buf.Append(ch); NextCh(); goto case 18;}
        else if ((ch == 'E' || ch == 'e')) {buf.Append(ch); NextCh(); goto case 8;}
        else {t.kind = 3; goto done;}
      case 8:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 10;}
        else if ((ch == '+' || ch == '-')) {buf.Append(ch); NextCh(); goto case 9;}
        else {t.kind = noSym; goto done;}
      case 9:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 10;}
        else {t.kind = noSym; goto done;}
      case 10:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 10;}
        else if ((ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm')) {buf.Append(ch); NextCh(); goto case 18;}
        else {t.kind = 3; goto done;}
      case 11:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 11;}
        else if ((ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm')) {buf.Append(ch); NextCh(); goto case 18;}
        else if ((ch == 'E' || ch == 'e')) {buf.Append(ch); NextCh(); goto case 12;}
        else {t.kind = 3; goto done;}
      case 12:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 14;}
        else if ((ch == '+' || ch == '-')) {buf.Append(ch); NextCh(); goto case 13;}
        else {t.kind = noSym; goto done;}
      case 13:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 14;}
        else {t.kind = noSym; goto done;}
      case 14:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 14;}
        else if ((ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm')) {buf.Append(ch); NextCh(); goto case 18;}
        else {t.kind = 3; goto done;}
      case 15:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 17;}
        else if ((ch == '+' || ch == '-')) {buf.Append(ch); NextCh(); goto case 16;}
        else {t.kind = noSym; goto done;}
      case 16:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 17;}
        else {t.kind = noSym; goto done;}
      case 17:
        if ((ch >= '0' && ch <= '9')) {buf.Append(ch); NextCh(); goto case 17;}
        else if ((ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm')) {buf.Append(ch); NextCh(); goto case 18;}
        else {t.kind = 3; goto done;}
      case 18:
        {t.kind = 3; goto done;}
      case 19:
        if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '&' || ch >= '(' && ch <= '[' || ch >= ']')) {buf.Append(ch); NextCh(); goto case 20;}
        else if (ch == 92) {buf.Append(ch); NextCh(); goto case 140;}
        else {t.kind = noSym; goto done;}
      case 20:
        if (ch == 39) {buf.Append(ch); NextCh(); goto case 35;}
        else {t.kind = noSym; goto done;}
      case 21:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 22;}
        else {t.kind = noSym; goto done;}
      case 22:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 141;}
        else if (ch == 39) {buf.Append(ch); NextCh(); goto case 35;}
        else {t.kind = noSym; goto done;}
      case 23:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 24;}
        else {t.kind = noSym; goto done;}
      case 24:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 25;}
        else {t.kind = noSym; goto done;}
      case 25:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 26;}
        else {t.kind = noSym; goto done;}
      case 26:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 20;}
        else {t.kind = noSym; goto done;}
      case 27:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 28;}
        else {t.kind = noSym; goto done;}
      case 28:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 29;}
        else {t.kind = noSym; goto done;}
      case 29:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 30;}
        else {t.kind = noSym; goto done;}
      case 30:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 31;}
        else {t.kind = noSym; goto done;}
      case 31:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 32;}
        else {t.kind = noSym; goto done;}
      case 32:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 33;}
        else {t.kind = noSym; goto done;}
      case 33:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 34;}
        else {t.kind = noSym; goto done;}
      case 34:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 20;}
        else {t.kind = noSym; goto done;}
      case 35:
        {t.kind = 4; goto done;}
      case 36:
        if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']')) {buf.Append(ch); NextCh(); goto case 36;}
        else if (ch == '"') {buf.Append(ch); NextCh(); goto case 52;}
        else if (ch == 92) {buf.Append(ch); NextCh(); goto case 143;}
        else {t.kind = noSym; goto done;}
      case 37:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 38;}
        else {t.kind = noSym; goto done;}
      case 38:
        if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '/' || ch >= ':' && ch <= '@' || ch >= 'G' && ch <= '[' || ch >= ']' && ch <= '`' || ch >= 'g')) {buf.Append(ch); NextCh(); goto case 36;}
        else if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 144;}
        else if (ch == '"') {buf.Append(ch); NextCh(); goto case 52;}
        else if (ch == 92) {buf.Append(ch); NextCh(); goto case 143;}
        else {t.kind = noSym; goto done;}
      case 39:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 40;}
        else {t.kind = noSym; goto done;}
      case 40:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 41;}
        else {t.kind = noSym; goto done;}
      case 41:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 42;}
        else {t.kind = noSym; goto done;}
      case 42:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 36;}
        else {t.kind = noSym; goto done;}
      case 43:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 44;}
        else {t.kind = noSym; goto done;}
      case 44:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 45;}
        else {t.kind = noSym; goto done;}
      case 45:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 46;}
        else {t.kind = noSym; goto done;}
      case 46:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 47;}
        else {t.kind = noSym; goto done;}
      case 47:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 48;}
        else {t.kind = noSym; goto done;}
      case 48:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 49;}
        else {t.kind = noSym; goto done;}
      case 49:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 50;}
        else {t.kind = noSym; goto done;}
      case 50:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 36;}
        else {t.kind = noSym; goto done;}
      case 51:
        if ((ch >= 1 && ch <= '!' || ch >= '#')) {buf.Append(ch); NextCh(); goto case 51;}
        else if (ch == '"') {buf.Append(ch); NextCh(); goto case 146;}
        else {t.kind = noSym; goto done;}
      case 52:
        {t.kind = 5; goto done;}
      case 53:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 159;}
        else if (ch == '&') {buf.Append(ch); NextCh(); goto case 172;}
        else {t.kind = 34; goto done;}
      case 54:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 174;}
        else {t.kind = 35; goto done;}
      case 55:
        {t.kind = 36; goto done;}
      case 56:
        {t.kind = 37; goto done;}
      case 57:
        if (ch == '-') {buf.Append(ch); NextCh(); goto case 58;}
        else if (ch == '=') {buf.Append(ch); NextCh(); goto case 153;}
        else if (ch == '>') {buf.Append(ch); NextCh(); goto case 177;}
        else {t.kind = 44; goto done;}
      case 58:
        {t.kind = 38; goto done;}
      case 59:
        if (ch == '+') {buf.Append(ch); NextCh(); goto case 60;}
        else if (ch == '=') {buf.Append(ch); NextCh(); goto case 152;}
        else {t.kind = 46; goto done;}
      case 60:
        {t.kind = 40; goto done;}
      case 61:
        {t.kind = 41; goto done;}
      case 62:
        {t.kind = 42; goto done;}
      case 63:
        {t.kind = 43; goto done;}
      case 64:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 173;}
        else {t.kind = 45; goto done;}
      case 65:
        {t.kind = 47; goto done;}
      case 66:
        {t.kind = 48; goto done;}
      case 67:
        {t.kind = 49; goto done;}
      case 68:
        {t.kind = 50; goto done;}
      case 69:
        {t.kind = 51; goto done;}
      case 70:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 154;}
        else {t.kind = 52; goto done;}
      case 71:
        if (ch == 'e') {buf.Append(ch); NextCh(); goto case 72;}
        else {t.kind = noSym; goto done;}
      case 72:
        if (ch == 'f') {buf.Append(ch); NextCh(); goto case 73;}
        else {t.kind = noSym; goto done;}
      case 73:
        if (ch == 'i') {buf.Append(ch); NextCh(); goto case 74;}
        else {t.kind = noSym; goto done;}
      case 74:
        if (ch == 'n') {buf.Append(ch); NextCh(); goto case 75;}
        else {t.kind = noSym; goto done;}
      case 75:
        if (ch == 'e') {buf.Append(ch); NextCh(); goto case 76;}
        else {t.kind = noSym; goto done;}
      case 76:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 77;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 76;}
        else {t.kind = noSym; goto done;}
      case 77:
        {t.kind = 129; goto done;}
      case 78:
        if (ch == 'n') {buf.Append(ch); NextCh(); goto case 79;}
        else {t.kind = noSym; goto done;}
      case 79:
        if (ch == 'd') {buf.Append(ch); NextCh(); goto case 80;}
        else {t.kind = noSym; goto done;}
      case 80:
        if (ch == 'e') {buf.Append(ch); NextCh(); goto case 81;}
        else {t.kind = noSym; goto done;}
      case 81:
        if (ch == 'f') {buf.Append(ch); NextCh(); goto case 82;}
        else {t.kind = noSym; goto done;}
      case 82:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 83;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 82;}
        else {t.kind = noSym; goto done;}
      case 83:
        {t.kind = 130; goto done;}
      case 84:
        if (ch == 'f') {buf.Append(ch); NextCh(); goto case 85;}
        else {t.kind = noSym; goto done;}
      case 85:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 86;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 85;}
        else {t.kind = noSym; goto done;}
      case 86:
        {t.kind = 131; goto done;}
      case 87:
        if (ch == 'f') {buf.Append(ch); NextCh(); goto case 88;}
        else {t.kind = noSym; goto done;}
      case 88:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 89;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 88;}
        else {t.kind = noSym; goto done;}
      case 89:
        {t.kind = 132; goto done;}
      case 90:
        if (ch == 'e') {buf.Append(ch); NextCh(); goto case 91;}
        else {t.kind = noSym; goto done;}
      case 91:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 92;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 91;}
        else {t.kind = noSym; goto done;}
      case 92:
        {t.kind = 133; goto done;}
      case 93:
        if (ch == 'f') {buf.Append(ch); NextCh(); goto case 94;}
        else {t.kind = noSym; goto done;}
      case 94:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 95;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 94;}
        else {t.kind = noSym; goto done;}
      case 95:
        {t.kind = 134; goto done;}
      case 96:
        if (ch == 'i') {buf.Append(ch); NextCh(); goto case 97;}
        else {t.kind = noSym; goto done;}
      case 97:
        if (ch == 'n') {buf.Append(ch); NextCh(); goto case 98;}
        else {t.kind = noSym; goto done;}
      case 98:
        if (ch == 'e') {buf.Append(ch); NextCh(); goto case 99;}
        else {t.kind = noSym; goto done;}
      case 99:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 100;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 99;}
        else {t.kind = noSym; goto done;}
      case 100:
        {t.kind = 135; goto done;}
      case 101:
        if (ch == 'r') {buf.Append(ch); NextCh(); goto case 102;}
        else {t.kind = noSym; goto done;}
      case 102:
        if (ch == 'o') {buf.Append(ch); NextCh(); goto case 103;}
        else {t.kind = noSym; goto done;}
      case 103:
        if (ch == 'r') {buf.Append(ch); NextCh(); goto case 104;}
        else {t.kind = noSym; goto done;}
      case 104:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 105;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 104;}
        else {t.kind = noSym; goto done;}
      case 105:
        {t.kind = 136; goto done;}
      case 106:
        if (ch == 'a') {buf.Append(ch); NextCh(); goto case 107;}
        else {t.kind = noSym; goto done;}
      case 107:
        if (ch == 'r') {buf.Append(ch); NextCh(); goto case 108;}
        else {t.kind = noSym; goto done;}
      case 108:
        if (ch == 'n') {buf.Append(ch); NextCh(); goto case 109;}
        else {t.kind = noSym; goto done;}
      case 109:
        if (ch == 'i') {buf.Append(ch); NextCh(); goto case 110;}
        else {t.kind = noSym; goto done;}
      case 110:
        if (ch == 'n') {buf.Append(ch); NextCh(); goto case 111;}
        else {t.kind = noSym; goto done;}
      case 111:
        if (ch == 'g') {buf.Append(ch); NextCh(); goto case 112;}
        else {t.kind = noSym; goto done;}
      case 112:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 113;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 112;}
        else {t.kind = noSym; goto done;}
      case 113:
        {t.kind = 137; goto done;}
      case 114:
        if (ch == 'e') {buf.Append(ch); NextCh(); goto case 115;}
        else {t.kind = noSym; goto done;}
      case 115:
        if (ch == 'g') {buf.Append(ch); NextCh(); goto case 116;}
        else {t.kind = noSym; goto done;}
      case 116:
        if (ch == 'i') {buf.Append(ch); NextCh(); goto case 117;}
        else {t.kind = noSym; goto done;}
      case 117:
        if (ch == 'o') {buf.Append(ch); NextCh(); goto case 118;}
        else {t.kind = noSym; goto done;}
      case 118:
        if (ch == 'n') {buf.Append(ch); NextCh(); goto case 119;}
        else {t.kind = noSym; goto done;}
      case 119:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 120;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 119;}
        else {t.kind = noSym; goto done;}
      case 120:
        {t.kind = 138; goto done;}
      case 121:
        if (ch == 'e') {buf.Append(ch); NextCh(); goto case 122;}
        else {t.kind = noSym; goto done;}
      case 122:
        if (ch == 'g') {buf.Append(ch); NextCh(); goto case 123;}
        else {t.kind = noSym; goto done;}
      case 123:
        if (ch == 'i') {buf.Append(ch); NextCh(); goto case 124;}
        else {t.kind = noSym; goto done;}
      case 124:
        if (ch == 'o') {buf.Append(ch); NextCh(); goto case 125;}
        else {t.kind = noSym; goto done;}
      case 125:
        if (ch == 'n') {buf.Append(ch); NextCh(); goto case 126;}
        else {t.kind = noSym; goto done;}
      case 126:
        if ((ch == 10 || ch == 13)) {buf.Append(ch); NextCh(); goto case 127;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14)) {buf.Append(ch); NextCh(); goto case 126;}
        else {t.kind = noSym; goto done;}
      case 127:
        {t.kind = 139; goto done;}
      case 128:
        if ((ch >= '0' && ch <= '9')) {apx = 0; buf.Append(ch); NextCh(); goto case 128;}
        else if (ch == 'U') {apx = 0; buf.Append(ch); NextCh(); goto case 132;}
        else if (ch == 'u') {apx = 0; buf.Append(ch); NextCh(); goto case 133;}
        else if (ch == 'L') {apx = 0; buf.Append(ch); NextCh(); goto case 134;}
        else if (ch == 'l') {apx = 0; buf.Append(ch); NextCh(); goto case 135;}
        else if (ch == '.') {apx++; buf.Append(ch); NextCh(); goto case 147;}
        else if ((ch == 'E' || ch == 'e')) {apx = 0; buf.Append(ch); NextCh(); goto case 15;}
        else if ((ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm')) {apx = 0; buf.Append(ch); NextCh(); goto case 18;}
        else {t.kind = 2; goto done;}
      case 129:
        if ((ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z' || ch == 196 || ch == 214 || ch == 220 || ch == 223 || ch == 228 || ch == 246 || ch == 252)) {buf.Append(ch); NextCh(); goto case 1;}
        else if (ch == '"') {buf.Append(ch); NextCh(); goto case 51;}
        else {t.kind = noSym; goto done;}
      case 130:
        if ((ch >= '0' && ch <= '9')) {apx = 0; buf.Append(ch); NextCh(); goto case 128;}
        else if (ch == 'U') {apx = 0; buf.Append(ch); NextCh(); goto case 132;}
        else if (ch == 'u') {apx = 0; buf.Append(ch); NextCh(); goto case 133;}
        else if (ch == 'L') {apx = 0; buf.Append(ch); NextCh(); goto case 134;}
        else if (ch == 'l') {apx = 0; buf.Append(ch); NextCh(); goto case 135;}
        else if (ch == '.') {apx++; buf.Append(ch); NextCh(); goto case 147;}
        else if ((ch == 'X' || ch == 'x')) {apx = 0; buf.Append(ch); NextCh(); goto case 3;}
        else if ((ch == 'E' || ch == 'e')) {apx = 0; buf.Append(ch); NextCh(); goto case 15;}
        else if ((ch == 'D' || ch == 'F' || ch == 'M' || ch == 'd' || ch == 'f' || ch == 'm')) {apx = 0; buf.Append(ch); NextCh(); goto case 18;}
        else {t.kind = 2; goto done;}
      case 131:
        if ((ch == 9 || ch >= 11 && ch <= 12 || ch == ' ')) {buf.Append(ch); NextCh(); goto case 131;}
        else if (ch == 'd') {buf.Append(ch); NextCh(); goto case 71;}
        else if (ch == 'u') {buf.Append(ch); NextCh(); goto case 78;}
        else if (ch == 'i') {buf.Append(ch); NextCh(); goto case 84;}
        else if (ch == 'e') {buf.Append(ch); NextCh(); goto case 148;}
        else if (ch == 'l') {buf.Append(ch); NextCh(); goto case 96;}
        else if (ch == 'w') {buf.Append(ch); NextCh(); goto case 106;}
        else if (ch == 'r') {buf.Append(ch); NextCh(); goto case 114;}
        else {t.kind = noSym; goto done;}
      case 132:
        if ((ch == 'L' || ch == 'l')) {buf.Append(ch); NextCh(); goto case 5;}
        else {t.kind = 2; goto done;}
      case 133:
        if ((ch == 'L' || ch == 'l')) {buf.Append(ch); NextCh(); goto case 5;}
        else {t.kind = 2; goto done;}
      case 134:
        if ((ch == 'U' || ch == 'u')) {buf.Append(ch); NextCh(); goto case 5;}
        else {t.kind = 2; goto done;}
      case 135:
        if ((ch == 'U' || ch == 'u')) {buf.Append(ch); NextCh(); goto case 5;}
        else {t.kind = 2; goto done;}
      case 136:
        if ((ch == 'L' || ch == 'l')) {buf.Append(ch); NextCh(); goto case 5;}
        else {t.kind = 2; goto done;}
      case 137:
        if ((ch == 'L' || ch == 'l')) {buf.Append(ch); NextCh(); goto case 5;}
        else {t.kind = 2; goto done;}
      case 138:
        if ((ch == 'U' || ch == 'u')) {buf.Append(ch); NextCh(); goto case 5;}
        else {t.kind = 2; goto done;}
      case 139:
        if ((ch == 'U' || ch == 'u')) {buf.Append(ch); NextCh(); goto case 5;}
        else {t.kind = 2; goto done;}
      case 140:
        if ((ch == '"' || ch == 39 || ch == '0' || ch == 92 || ch >= 'a' && ch <= 'b' || ch == 'f' || ch == 'n' || ch == 'r' || ch == 't' || ch == 'v')) {buf.Append(ch); NextCh(); goto case 20;}
        else if (ch == 'x') {buf.Append(ch); NextCh(); goto case 21;}
        else if (ch == 'u') {buf.Append(ch); NextCh(); goto case 23;}
        else if (ch == 'U') {buf.Append(ch); NextCh(); goto case 27;}
        else {t.kind = noSym; goto done;}
      case 141:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 142;}
        else if (ch == 39) {buf.Append(ch); NextCh(); goto case 35;}
        else {t.kind = noSym; goto done;}
      case 142:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 20;}
        else if (ch == 39) {buf.Append(ch); NextCh(); goto case 35;}
        else {t.kind = noSym; goto done;}
      case 143:
        if ((ch == '"' || ch == 39 || ch == '0' || ch == 92 || ch >= 'a' && ch <= 'b' || ch == 'f' || ch == 'n' || ch == 'r' || ch == 't' || ch == 'v')) {buf.Append(ch); NextCh(); goto case 36;}
        else if (ch == 'x') {buf.Append(ch); NextCh(); goto case 37;}
        else if (ch == 'u') {buf.Append(ch); NextCh(); goto case 39;}
        else if (ch == 'U') {buf.Append(ch); NextCh(); goto case 43;}
        else {t.kind = noSym; goto done;}
      case 144:
        if ((ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f')) {buf.Append(ch); NextCh(); goto case 145;}
        else if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '/' || ch >= ':' && ch <= '@' || ch >= 'G' && ch <= '[' || ch >= ']' && ch <= '`' || ch >= 'g')) {buf.Append(ch); NextCh(); goto case 36;}
        else if (ch == '"') {buf.Append(ch); NextCh(); goto case 52;}
        else if (ch == 92) {buf.Append(ch); NextCh(); goto case 143;}
        else {t.kind = noSym; goto done;}
      case 145:
        if ((ch >= 1 && ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']')) {buf.Append(ch); NextCh(); goto case 36;}
        else if (ch == '"') {buf.Append(ch); NextCh(); goto case 52;}
        else if (ch == 92) {buf.Append(ch); NextCh(); goto case 143;}
        else {t.kind = noSym; goto done;}
      case 146:
        if (ch == '"') {buf.Append(ch); NextCh(); goto case 51;}
        else {t.kind = 5; goto done;}
      case 147:
        if ((ch >= 1 && ch <= '/' || ch >= ':')) {apx++; buf.Append(ch); NextCh(); goto case 2;}
        else if ((ch >= '0' && ch <= '9')) {apx = 0; buf.Append(ch); NextCh(); goto case 11;}
        else {t.kind = noSym; goto done;}
      case 148:
        if (ch == 'l') {buf.Append(ch); NextCh(); goto case 149;}
        else if (ch == 'n') {buf.Append(ch); NextCh(); goto case 150;}
        else if (ch == 'r') {buf.Append(ch); NextCh(); goto case 101;}
        else {t.kind = noSym; goto done;}
      case 149:
        if (ch == 'i') {buf.Append(ch); NextCh(); goto case 87;}
        else if (ch == 's') {buf.Append(ch); NextCh(); goto case 90;}
        else {t.kind = noSym; goto done;}
      case 150:
        if (ch == 'd') {buf.Append(ch); NextCh(); goto case 151;}
        else {t.kind = noSym; goto done;}
      case 151:
        if (ch == 'i') {buf.Append(ch); NextCh(); goto case 93;}
        else if (ch == 'r') {buf.Append(ch); NextCh(); goto case 121;}
        else {t.kind = noSym; goto done;}
      case 152:
        {t.kind = 94; goto done;}
      case 153:
        {t.kind = 95; goto done;}
      case 154:
        {t.kind = 96; goto done;}
      case 155:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 156;}
        else {t.kind = 125; goto done;}
      case 156:
        {t.kind = 97; goto done;}
      case 157:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 158;}
        else {t.kind = 126; goto done;}
      case 158:
        {t.kind = 98; goto done;}
      case 159:
        {t.kind = 99; goto done;}
      case 160:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 161;}
        else if (ch == '|') {buf.Append(ch); NextCh(); goto case 171;}
        else {t.kind = 113; goto done;}
      case 161:
        {t.kind = 100; goto done;}
      case 162:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 163;}
        else {t.kind = 114; goto done;}
      case 163:
        {t.kind = 101; goto done;}
      case 164:
        if (ch == '<') {buf.Append(ch); NextCh(); goto case 165;}
        else if (ch == '=') {buf.Append(ch); NextCh(); goto case 175;}
        else {t.kind = 117; goto done;}
      case 165:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 166;}
        else {t.kind = 123; goto done;}
      case 166:
        {t.kind = 102; goto done;}
      case 167:
        if (ch == '>') {buf.Append(ch); NextCh(); goto case 168;}
        else if (ch == '=') {buf.Append(ch); NextCh(); goto case 176;}
        else {t.kind = 118; goto done;}
      case 168:
        if (ch == '=') {buf.Append(ch); NextCh(); goto case 169;}
        else {t.kind = 124; goto done;}
      case 169:
        {t.kind = 103; goto done;}
      case 170:
        {t.kind = 110; goto done;}
      case 171:
        {t.kind = 111; goto done;}
      case 172:
        {t.kind = 112; goto done;}
      case 173:
        {t.kind = 115; goto done;}
      case 174:
        {t.kind = 116; goto done;}
      case 175:
        {t.kind = 119; goto done;}
      case 176:
        {t.kind = 120; goto done;}
      case 177:
        {t.kind = 127; goto done;}
      case 178: {t.kind = 0; goto done;}
    }
    done: 
    t.val = buf.ToString();
    return t;
  }
  
  /* AW 2003-03-07 get the next token, move on and synch peek token with current */
  public static Token Scan () {
    t = pt = t.next;
    return t;
  }

  /* AW 2003-03-07 get the next token, ignore pragmas */
  public static Token Peek () {
    do {                      // skip pragmas while peeking
      pt = pt.next;
    } while (pt.kind > maxT);
    return pt;
  }
  
  /* AW 2003-03-11 to make sure peek start at current scan position */
  public static void ResetPeek () { pt = t; }
} // end Scanner

}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.