예제 #1
0
        public override Tree <Binding> VisitVariable(gramParser.VariableContext context)
        {
            var name = context.IDENTIFIER().GetText();

            if (context.expr() != null)
            {
                var type = interpreter.Visit(context.expr());
                if (type.Type.Check(ValueType.TYPE))
                {
                    return(new Tree <Binding>(new Binding(name, type.Get <IType>())));
                }
                else if (type.Type.Check(ValueType.LIST))
                {
                    return(new Tree <Binding>(new Binding(name, new ListType(type.Get <IEnumerable <IValue> >(), context.expr().GetText()))));
                }
            }

            return(new Tree <Binding>(new Binding(name)));
        }
예제 #2
0
 public override IValue VisitVariable(gramParser.VariableContext context)
 {
     return(environment[context.IDENTIFIER().GetText()].Value);
 }