示例#1
0
文件: E2Parser.cs 项目: itsbth/E2Edit
 public E2Parser(string text)
 {
     _text = text;
     _lines = text.Split(new[] {'\r', '\n'});
     _reader = new E2Tokenizer(text);
     Variables = new List<Variable>();
 }
示例#2
0
文件: Program.cs 项目: itsbth/E2Edit
 private static void TestTokenizer()
 {
     var reader = new E2Tokenizer(File.ReadAllText(@"C:\Games\Steam\steamapps\itsbth\garrysmod\garrysmod\data\Expression2\datareceiver.txt"));
     Token t;
     int ind = 0;
     bool c = true;
     while ((t = reader.Read()).Type != Token.TokenType.EOF)
     {
         switch(t.Type)
         {
             case Token.TokenType.String:
                 Console.ForegroundColor = ConsoleColor.Green;
                 break;
             case Token.TokenType.Comment:
                 Console.ForegroundColor = ConsoleColor.Gray;
                 break;
             case Token.TokenType.Symbol:
                 Console.ForegroundColor = ConsoleColor.Blue;
                 break;
             default:
                 Console.ForegroundColor = ConsoleColor.White;
                 break;
         }
         if (t.Type == Token.TokenType.Symbol && t.Value != ",") Console.Write(" ");
         Console.Write(t.Value);
         if (t.Type == Token.TokenType.Symbol) Console.Write(" ");
         if (t.Type == Token.TokenType.NewLine) Console.Write(new string('\t', ind));
         if (t.Type == Token.TokenType.BracketStart) ind += 1;
         else if (t.Type == Token.TokenType.BracketEnd) ind -= 1;
         c = !c;
     }
     Console.Read();
 }