public E2Parser(string text) { _text = text; _lines = text.Split(new[] {'\r', '\n'}); _reader = new E2Tokenizer(text); Variables = new List<Variable>(); }
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(); }