コード例 #1
0
            public override void Build(ref SourceCode code, ref Script script, ScriptEngine engine, ConfigBuilder config)
            {
                var items = new Dictionary<string, List<Token>>();

                code += _identifier.Length;
                if (code.Peek() != '{')
                {
                    throw new Exception("Syntax Error: Expected a {");
                }

                code.SeekToNext('{');

                while (!(++code).EOF && code.Peek() != '}')
                {
                    // We are expecting: identifier = (code);
                    while (code.SpecialChar)
                    {
                        code++;
                    }
                    string id = "";
                    bool space = false;
                    while (!code.EOF && code.CurrentCode != '=')
                    {
                        if (code.CurrentCode == ' ')
                        {
                            space = true;
                        }
                        else
                        {
                            if (space)
                            {
                                code--; // Rewind, so the error is where the space is.
                                code.Throw("Unexpected whitespace...");
                            }
                            id += code.CurrentCode;
                        }
                        code++;
                    }
                    if (code.EOF)
                    {
                        code.Throw("Unexpected EOF");
                    }
                    // Otherwise
                    code++;

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

                    items.Add(id, tokens);
                }

                code.SeekToNext('}');

                config.AddReturnElement(_identifier, items);
            }
コード例 #2
0
 public override void Build(ref SourceCode code, ref Script script, ScriptEngine engine, ConfigBuilder config)
 {
     string id = "";
     code += _identifier.Length;
     if (code.Peek() == '{' && _requiresID)
     {
         throw new Exception("Script block requires an ID.");
     }
     if (code.Peek() != '{')
     {
         code.SeekToNext('"');
         while (!(++code).EOF && code.CurrentCode != '"')
         {
             id += code.CurrentCode;
         }
         if (code.EOF)
         {
             code.Throw("Unexpected EOF");
         }
     }
     code.SeekToNext('{');
     var c = new Code(engine.BuildLongTokens(ref code, ref script, new[] {'}'}),
                      new Script(engine) {UseEngineGlobals = false});
     config.AddReturnElement(_identifier, new ScriptBlock {Code = c, Identifier = id});
 }
コード例 #3
0
 public abstract void Build(ref SourceCode code, ref Script script, ScriptEngine engine, ConfigBuilder config);