Esempio n. 1
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     _condition.Accept(visitor);
     _ifTrue.Accept(visitor);
     _ifFalse.Accept(visitor);
 }
Esempio n. 2
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     Target?.Accept(visitor);
     _upperBound?.Accept(visitor);
     _lowerBound?.Accept(visitor);
 }
Esempio n. 3
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     foreach (var arg in Arguments)
     {
         arg.Accept(visitor);
     }
 }
Esempio n. 4
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     foreach (var projection in _projections)
     {
         projection.Accept(visitor);
     }
 }
Esempio n. 5
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     foreach (var expr in _exprs)
     {
         expr.Accept(visitor);
     }
 }
Esempio n. 6
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     _leftHandSide.Accept(visitor);
     foreach (var arg in _arguments.Values)
     {
         arg.Accept(visitor);
     }
 }
Esempio n. 7
0
        public override IStatementObject VisitCalculateStatement(SuperReadableParser.CalculateStatementContext context)
        {
            var expr = context.GetRuleContext <SuperReadableParser.ExprContext>(0);

            var visitor = new ExprVisitor();
            var exprObj = visitor.Visit(expr);

            return(new CalculateStatementObject(exprObj));
        }
Esempio n. 8
0
        public Expr Parse(string expression)
        {
            var input  = new AntlrInputStream(expression);
            var lexer  = new ExprLexer(input);
            var tokens = new CommonTokenStream(lexer);
            var parser = new ExprParser(tokens);

            var visitor = new ExprVisitor();

            return(visitor.Visit(parser.expr()));
        }
Esempio n. 9
0
        public override IStatementObject VisitIfStatement(SuperReadableParser.IfStatementContext context)
        {
            var flag = context.GetRuleContext <SuperReadableParser.ExprContext>(0);

            var visitor = new ExprVisitor();
            var flagObj = visitor.Visit(flag);

            var ifStatementObj = new IfStatementObject(flagObj);

            var statements = context.GetRuleContexts <SuperReadableParser.StatementContext>();

            foreach (var statement in statements)
            {
                var statementObj = Visit(statement);
                ifStatementObj.Children.Add(statementObj);
            }

            return(ifStatementObj);
        }
Esempio n. 10
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)));
        }
Esempio n. 11
0
 protected internal virtual ExprAST VisitChildren(ExprVisitor visitor)
 {
     return visitor.Visit(this);
 }
Esempio n. 12
0
 protected internal virtual ExprAST VisitChildren(ExprVisitor visitor)
 {
     return(visitor.Visit(this));
 }
Esempio n. 13
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     _innerExpression.Accept(visitor);
 }
Esempio n. 14
0
 public override R Accept <R>(ExprVisitor <R> visitor)
 {
     return(visitor.Visit(this));
 }
Esempio n. 15
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     Target.Accept(visitor);
     Condition.Accept(visitor);
 }
Esempio n. 16
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     SpreadObject.Accept(visitor);
 }
Esempio n. 17
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     _message.Accept(visitor);
 }
Esempio n. 18
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     LeftHandSide.Accept(visitor);
     RightHandSide.Accept(visitor);
 }
Esempio n. 19
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     _obj.Accept(visitor);
     _ifIsError.Accept(visitor);
 }
Esempio n. 20
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
 }
Esempio n. 21
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     Target?.Accept(visitor);
     _index.Accept(visitor);
 }
Esempio n. 22
0
        //public static void Accept(this ConnectiveExpr visitee, ExprVisitor visitor) => visitor.Visit(visitee);
        public static Result Accept <Result>(this Expr visitee, ExprVisitor <Result> visitor)
        {
            var result  = default(Result);
            var visited = TryVisitConcreteExpr <ConnectiveExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <PowerExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <MultiplicativeExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <DivisiveExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <ModuloExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <AdditiveExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <SubtractiveExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <FloatLiteral, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <TrackSetLiteral, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <AssocArrayLiteral, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <IdentifierExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <LambdaExpr, Result>(visitee, ref result, c => visitor.Visit(c)) ||
                          TryVisitConcreteExpr <ModuleParamExpr, Result>(visitee, ref result, c => visitor.Visit(c))
            ;

            if (!visited)
            {
                throw new Exception($"unknown Command type: {visitee.GetType()}");
            }

            return(result);
        }
Esempio n. 23
0
        public IValue Execute(string code)
        {
            var parser = getParser(code);

            return(interpreter.Visit(parser.prog()));
        }
Esempio n. 24
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     Value.Accept(visitor);
     _pipedInto.Accept(visitor);
 }
Esempio n. 25
0
 internal override void Accept(ExprVisitor visitor)
 {
     visitor.Visit(this);
     First.Accept(visitor);
     Next.Accept(visitor);
 }