Esempio n. 1
0
        public override int VisitExprHelpForMethods(RParser.ExprHelpForMethodsContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RHelpForMethods(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.left, ContextType.CT_EXPR_HELP_FOR_METHODS_LEFT);
            VisitElementInContext(context.right, ContextType.CT_EXPR_HELP_FOR_METHODS_RIGHT);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 2
0
        public override int VisitExprIndexingBasic(RParser.ExprIndexingBasicContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RIndexingBasic(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.arraybase, ContextType.CT_EXPR_INDEXING_BASIC_BASE);
            VisitElementInContext(context.arrayoffset, ContextType.CT_EXPR_INDEXING_BASIC_OFFSET);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 3
0
        public override int VisitExprWrappedWithPercent(RParser.ExprWrappedWithPercentContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RWrappedWithPercent(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.left, ContextType.CT_EXPR_WRAPPED_WITH_PERCENT_LEFT);
            VisitElementInContext(context.right, ContextType.CT_EXPR_WRAPPED_WITH_PERCENT_RIGHT);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 4
0
        public override int VisitExprWhile(RParser.ExprWhileContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RWhile(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.whilecond, ContextType.CT_EXPR_WHILE_CONDITION);
            VisitElementInContext(context.whilebody, ContextType.CT_EXPR_WHILE_BODY);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 5
0
        public override int VisitExprDollarAtOperators(RParser.ExprDollarAtOperatorsContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RDollarAtOperators(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.left, ContextType.CT_EXPR_DOLLAR_AT_OPERATORS_BASE);
            VisitElementInContext(context.right, ContextType.CT_EXPR_DOLLAR_AT_OPERATORS_OFFSET);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 6
0
        public override int VisitExprIfElseStatement(RParser.ExprIfElseStatementContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RIfElseStatement(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.ifcond, ContextType.CT_EXPR_IF_ELSE_STATEMENT_CONDITION);
            VisitElementInContext(context.thenbody, ContextType.CT_EXPR_IF_ELSE_STATEMENT_IFBODY);
            VisitElementInContext(context.elsebody, ContextType.CT_EXPR_IF_ELSE_STATEMENT_ELSEBODY);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 7
0
        public override int VisitExprFor(RParser.ExprForContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RFor(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.ID(), ContextType.CT_EXPR_FOR_NAME);
            VisitElementInContext(context.for_list, ContextType.CT_EXPR_FOR_VECTOR);
            VisitElementInContext(context.for_body, ContextType.CT_EXPR_FOR_BODY);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 8
0
        public override int VisitExprCallFunction(RParser.ExprCallFunctionContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RCallFunction(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.funid, ContextType.CT_EXPR_CALL_FUNCTION_ID);
            VisitElementInContext(context.funargs, ContextType.CT_EXPR_CALL_FUNCTION_PARAMS);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 9
0
        public override int VisitExprAssignmentOpetators(RParser.ExprAssignmentOpetatorsContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RASsignmentOpetators(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.left, ContextType.CT_EXPR_ASSIGNMENT_OPETATORS_LEFT);
            VisitElementInContext(context.right, ContextType.CT_EXPR_ASSIGNMENT_OPETATORS_RIGHT);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 10
0
        public override int VisitExprTildeBinary(RParser.ExprTildeBinaryContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RTildeBinary(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.left, ContextType.CT_EXPR_TILDE_BINARY_LEFT);
            VisitElementInContext(context.right, ContextType.CT_EXPR_TILDE_BINARY_RIGHT);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 11
0
 public RASTElementDescentantsContextIterator(RASTElement astNode)
 {
     m_node = astNode as RASTComposite;
     if (m_node == null)
     {
         throw new Exception("Iterator cannot iterate over leaf nodes");
     }
 }
Esempio n. 12
0
 public RASTElementDescentantsFlattenEventIterator(RASTElement astNode,
                                                   RASTGenericIteratorEvents events, object info = null)
 {
     m_Event = events;
     m_node  = astNode as RASTComposite;
     if (m_node == null)
     {
         throw new Exception("Iterator cannot iterate over leaf nodes");
     }
 }
        public override int VisitAssignmentOpetators(RASTElement currentNode)
        {
            RASTComposite current = currentNode as RASTComposite;

            // Visit assignment opetator left context
            if (current.GetNumberOfContextElements(ContextType.CT_EXPR_ASSIGNMENT_OPETATORS_LEFT) > 0)
            {
                foreach (RASTElement element in current.GetContextChildren(ContextType.CT_EXPR_ASSIGNMENT_OPETATORS_LEFT))
                {
                    scopeSystem.AddSymbol(element.M_Label, "Local Variable");
                }
            }

            base.VisitAssignmentOpetators(currentNode);

            return(0);
        }
        public override int VisitDefineFunction(RASTElement currentNode)
        {
            RASTComposite current = currentNode as RASTComposite;

            scopeSystem.EnterEnviroment(currentNode.M_Label);

            // Visit function's definition params context
            if (current.GetNumberOfContextElements(ContextType.CT_EXPR_DEFINE_FUNCTION_PARAMS) > 0)
            {
                foreach (RASTElement element in current.GetContextChildren(ContextType.CT_EXPR_DEFINE_FUNCTION_PARAMS))
                {
                    scopeSystem.AddSymbol(element.M_Label, "Formal Parameter");
                }
            }

            base.VisitDefineFunction(currentNode);

            scopeSystem.LeaveEnviroment();

            return(0);
        }
Esempio n. 15
0
        public override int VisitProg(RParser.ProgContext context)
        {
            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RProg();

            // Update root
            m_root = newElement;
            // Update parents stack
            m_parents.Push(newElement);

            // VISIT CHILDREN
            VisitElementsInContext(context._expressions, ContextType.CT_PROG);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 16
0
        public override int VisitExprParenthesis(RParser.ExprParenthesisContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RParenthesis(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.expr(), ContextType.CT_EXPR_PARENTHESIS);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 17
0
        public override int VisitExprBreakStatement(RParser.ExprBreakStatementContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RBreakStatement(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            //VisitElementInContext(context., ContextType.CT_EXPR_BREAK_STATEMENT);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 18
0
        public override int VisitExprNextStatement(RParser.ExprNextStatementContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RNextStatement(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN


            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 19
0
        public override int VisitExprMinusOrPlusUnary(RParser.ExprMinusOrPlusUnaryContext context)
        {
            RASTComposite parent = m_parents.Peek();

            // PREORDER ACTIONS
            // Create new element
            RASTComposite newElement = new RMinusOrPlusUnary(parent);

            // Update parents stack
            m_parents.Push(newElement);

            // Add new element to the parent's descentants
            parent.AddChild(newElement, m_currentContext.Peek());

            // VISIT CHILDREN
            VisitElementInContext(context.expr(), ContextType.CT_EXPR_MINUS_OR_PLUS_UNARY);

            // POSTORDER ACTIONS

            // Update parents stack
            m_parents.Pop();

            return(0);
        }
Esempio n. 20
0
        public override int VisitTerminal(ITerminalNode node)
        {
            RASTComposite parent = m_parents.Peek();

            switch (node.Symbol.Type)
            {
            case RParser.ID:
                RIDENTIFIER identifierToken = new RIDENTIFIER(node.GetText(), parent);
                parent.AddChild(identifierToken, m_currentContext.Peek());
                break;

            case RParser.STRING:
                RSTRING stringToken = new RSTRING(node.GetText().Replace('"', ' '), parent);
                parent.AddChild(stringToken, m_currentContext.Peek());
                break;

            case RParser.HEX:
                RHEX hexToken = new RHEX(node.GetText(), parent);
                parent.AddChild(hexToken, m_currentContext.Peek());
                break;

            case RParser.INT:
                RINTEGER integerToken = new RINTEGER(node.GetText(), parent);
                parent.AddChild(integerToken, m_currentContext.Peek());
                break;

            case RParser.FLOAT:
                RFLOAT floatToken = new RFLOAT(node.GetText(), parent);
                parent.AddChild(floatToken, m_currentContext.Peek());
                break;

            case RParser.COMPLEX:
                RCOMPLEX complexToken = new RCOMPLEX(node.GetText(), parent);
                parent.AddChild(complexToken, m_currentContext.Peek());
                break;

            case 47:        // 'NULL'
                RLITERALSPECIFIER NULL_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(NULL_literal, m_currentContext.Peek());
                break;

            case 48:        // 'NA'
                RLITERALSPECIFIER NA_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(NA_literal, m_currentContext.Peek());
                break;

            case 49:        // 'NA_integer_'
                RLITERALSPECIFIER NA_integer_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(NA_integer_literal, m_currentContext.Peek());
                break;

            case 50:        // 'NA_real_'
                RLITERALSPECIFIER NA_real_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(NA_real_literal, m_currentContext.Peek());
                break;

            case 51:        // 'NA_complex_'
                RLITERALSPECIFIER NA_complex_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(NA_complex_literal, m_currentContext.Peek());
                break;

            case 52:        // 'NA_character_'
                RLITERALSPECIFIER NA_character_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(NA_character_literal, m_currentContext.Peek());
                break;

            case 53:        // 'Inf'
                RLITERALSPECIFIER Inf_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(Inf_literal, m_currentContext.Peek());
                break;

            case 54:        // 'NaN'
                RLITERALSPECIFIER NaN_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(NaN_literal, m_currentContext.Peek());
                break;

            case 55:        // 'TRUE'
                RLITERALSPECIFIER TRUE_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(TRUE_literal, m_currentContext.Peek());
                break;

            case 56:        // 'FALSE'
                RLITERALSPECIFIER FALSE_literal = new RLITERALSPECIFIER(node.GetText(), parent);
                parent.AddChild(FALSE_literal, m_currentContext.Peek());
                break;
            }

            return(base.VisitTerminal(node));
        }