1 using System;
  
   2 using System.Collections;
  
   3 
  
   4 
  
   5 
  
   6 
  
   7 
  
   8 public class TrivialLexer : System.Lex.Lexer
  
   9 {
  
  10     public TrivialLexer(const ustring& content_, const string& fileName_, int fileIndex_) : 
  
  11         base(content_, fileName_, fileIndex_)
  
  12     {
  
  13     }
  
  14     public TrivialLexer(const uchar* start_, const uchar* end_, const string& fileName_, int fileIndex_) : 
  
  15         base(start_, end_, fileName_, fileIndex_)
  
  16     {
  
  17     }
  
  18     public override int NextState(int state, uchar c)
  
  19     {
  
  20         token.id = cast<int>(c);
  
  21         token.match = lexeme;
  
  22         if (c == '\n')
  
  23         {
  
  24             ++line;
  
  25         }
  
  26         return -1;
  
  27     }
  
  28 }
  
  29 public string GetTrivialTokenInfo(int tokenId)
  
  30 {
  
  31     if (tokenId == System.Lex.END_TOKEN)
  
  32     {
  
  33         return "end of file";
  
  34     }
  
  35     return ToString(tokenId);
  
  36 }