Beispiel #1
0
 object AssignObject(object obj, Type objType, ObjectLiteralExpression literal, EvalEnv env)
 {
     throw new NotImplementedException ();
 }
Beispiel #2
0
        static ObjectLiteralExpression ParseObjectLiteral(Token[] toks, ref int p)
        {
            var e = new ObjectLiteralExpression ();

            var end = toks.Length;

            p++; // Consume '{'

            while (p < end) {
                var t = toks[p];
                if (t.Type == TokenType.Identifier || t.Type == TokenType.String) {
                    var ident = t.ToString ();
                    p++;
                    if (p < end && (toks[p].Type == TokenType.Colon || toks[p].Type == TokenType.Assign)) {
                        p++;
                        if (p < end) {
                            var val = Parse (toks, ref p);
                            e.Add (ident, val);
                        }
                    }
                }
                else if (t.Type == TokenType.RightCurly) {
                    p++;
                    break;
                }
                else {
                    // Unexpected. Just keep reading until we get to a right curly
                    p++;
                }
            }

            return e;
        }