예제 #1
0
        public override Expression Scan(ParseEngine engine)
        {
            var index = engine.Pointer;
            var chars = engine.Characters;

            if (ParseEngine.IsIdentifierStart(chars[index]))
            {
                index++;

                while (index < chars.Length && ParseEngine.IsIdentifierPart(chars[index]))
                {
                    index++;
                }

                var name = new String(chars, engine.Pointer, index - engine.Pointer);

                if (engine.UseKeywords)
                {
                    var keyword = engine.Elements.FindKeywordExpression(name, engine);

                    if (keyword != null)
                    {
                        return(keyword);
                    }
                }

                var exp = new SymbolExpression(engine, name);
                engine.SetPointer(index);
                return(exp);
            }

            return(null);
        }
예제 #2
0
        Value Assign(SymbolExpression left, Value value, IDictionary <String, Value> symbols)
        {
            if (symbols.ContainsKey(left.SymbolName))
            {
                symbols[left.SymbolName] = value.Copy();
            }
            else
            {
                Context.AssignVariable(left.SymbolName, value.Copy());
            }

            return(value);
        }
예제 #3
0
        public static Boolean IsAssigned(this ContainerExpression container, SymbolExpression symbol)
        {
            var expressions = container.Expressions;

            if (expressions.Length > 0)
            {
                var leftExpression = expressions[0];
                container = leftExpression as ContainerExpression;

                if (container != null)
                {
                    return(container.IsAssigned(symbol));
                }

                return(Object.ReferenceEquals(leftExpression, symbol));
            }

            return(false);
        }