Exemplo n.º 1
0
        public override Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
        {
            // using (arg1, arg2, arg3) { }

            sourceCode += 5;

            if (!sourceCode.SeekToNext('('))
            {
                sourceCode.Throw("Expected (");
            }

            // Build up the arguments.
            Dictionary<string, List<Token>> items = new Dictionary<string, List<Token>>();

            while (sourceCode.CurrentCode != ')')
            {

                string name = sourceCode.NextWord();

                if (sourceCode.CurrentCode != '=')
                {
                    sourceCode.Throw(String.Format("Unexpected character, {0}.", sourceCode.CurrentCode));
                }

                // Otherwise...
                List<Token> code = engine.BuildTokens(ref sourceCode, ref script, new char[] {',', ')'});

                items.Add(name, code);

            }

            if (!sourceCode.SeekToNext('{'))
            {
                sourceCode.Throw(String.Format("Unexpected character, {0}", sourceCode.NextCode));
            }

            List<List<List<Token>>> codeBlock = engine.BuildLongTokens(ref sourceCode, ref script, new char[] {'}'});

            return new UsingToken(items, codeBlock);
        }