static void Run(string code) { List <CodeTokenizer.Token> tokens = null; StatementBlock block = null; try { tokens = CodeTokenizer.Tokenize(code, file); var tokensEnum = (IEnumerator <CodeTokenizer.Token>)tokens.GetEnumerator(); block = TokenParser.Parse(ref tokensEnum, enviroment, CodePosition.GetExternal()); } catch (WordScriptException ex) { Console.WriteLine(ex.Message); } if (tokens != null) { foreach (var token in tokens) { Console.WriteLine(token.ToString()); } } Console.WriteLine(""); if (block != null) { foreach (var node in block.GetSyntaxNodes()) { Console.WriteLine(node.Debug()); } var ret = block.Evaluate(); Console.WriteLine(ret?.ToString() ?? "null"); } }
public void Tokenizing() { var tokens = CodeTokenizer.Tokenize("print IN add \"Hello\" \"world\" . .\n mul 5 10 , string , add \" = 25\" , print ."); Assert.AreEqual(tokens.Count, 18); }