public override int VisitExpr_PLUSMINUS(MINICParser.Expr_PLUSMINUSContext context) { ASTComposite m_parent = m_parents.Peek(); if (context.op.Type == MINICParser.MINUS) { CASTExpressionSubtraction newnode = new CASTExpressionSubtraction(context.GetText(), m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(0), m_parentContext, contextType.CT_EXPRESSION_SUBTRACTION_LEFT); this.VisitElementInContext(context.expression(1), m_parentContext, contextType.CT_EXPRESSION_SUBTRACTION_RIGHT); } else if (context.op.Type == MINICParser.PLUS) { CASTExpressionAddition newnode = new CASTExpressionAddition(context.GetText(), m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(0), m_parentContext, contextType.CT_EXPRESSION_ADDITION_LEFT); this.VisitElementInContext(context.expression(1), m_parentContext, contextType.CT_EXPRESSION_ADDITION_RIGHT); } m_parents.Pop(); return(0); }
public override int VisitStatement_BreakStatement(MINICParser.Statement_BreakStatementContext context) { ASTComposite m_parent = m_parents.Peek(); CASTBreakStatement newnode = new CASTBreakStatement(context.GetText(), m_parents.Peek(), 0); m_parent.AddChild(newnode, m_parentContext.Peek()); return(0); }
public override int VisitTerminal(ITerminalNode node) { ASTComposite m_parent = m_parents.Peek(); switch (node.Symbol.Type) { case MINICLexer.NUMBER: CASTNUMBER newnode1 = new CASTNUMBER(node.Symbol.Text, m_parents.Peek()); m_parent.AddChild(newnode1, m_parentContext.Peek()); break; case MINICLexer.IDENTIFIER: CASTIDENTIFIER newnode2 = new CASTIDENTIFIER(node.Symbol.Text, m_parents.Peek()); m_parent.AddChild(newnode2, m_parentContext.Peek()); break; default: break; } return(base.VisitTerminal(node)); }
public override int VisitExpr_PLUS(MINICParser.Expr_PLUSContext context) { ASTComposite m_parent = m_parents.Peek(); CASTExpressionPlus newnode = new CASTExpressionPlus(context.GetText(), m_parents.Peek(), 1); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(), m_parentContext, contextType.CT_EXPRESSION_PLUS); m_parents.Pop(); return(0); }
public override int VisitStatement_ReturnStatement(MINICParser.Statement_ReturnStatementContext context) { ASTComposite m_parent = m_parents.Peek(); CASTReturnStatement newnode = new CASTReturnStatement(context.GetText(), m_parents.Peek(), 1); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(), m_parentContext, contextType.CT_STATEMENT_RETURN); m_parents.Pop(); return(0); }
public override int VisitWhilestatement(MINICParser.WhilestatementContext context) { ASTComposite m_parent = m_parents.Peek(); CASTWhileStatement newnode = new CASTWhileStatement(context.GetText(), m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(), m_parentContext, contextType.CT_WHILESTATEMENT_CONDITION); this.VisitElementInContext(context.statement(), m_parentContext, contextType.CT_WHILESTATEMENT_BODY); m_parents.Pop(); return(0); }
public override int VisitCompoundStatement(MINICParser.CompoundStatementContext context) { ASTComposite m_parent = m_parents.Peek(); CASTCompoundStatement newnode = new CASTCompoundStatement(context.GetText(), m_parents.Peek(), 1); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.statementList(), m_parentContext, contextType.CT_COMPOUNDSTATEMENT); m_parents.Pop(); return(0); }
public override int VisitExpr_ASSIGN(MINICParser.Expr_ASSIGNContext context) { ASTComposite m_parent = m_parents.Peek(); CASTExpressionAssign newnode = new CASTExpressionAssign(context.GetText(), m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitTerminalInContext(context, context.IDENTIFIER().Symbol, m_parentContext, contextType.CT_EXPRESSION_ASSIGN_LVALUE); this.VisitElementInContext(context.expression(), m_parentContext, contextType.CT_EXPRESSION_ASSIGN_EXPRESSION); m_parents.Pop(); return(0); }
public override int VisitExpr_NEQUAL(MINICParser.Expr_NEQUALContext context) { ASTComposite m_parent = m_parents.Peek(); CASTExpressionNequal newnode = new CASTExpressionNequal(context.GetText(), m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(0), m_parentContext, contextType.CT_EXPRESSION_NEQUAL_LEFT); this.VisitElementInContext(context.expression(1), m_parentContext, contextType.CT_EXPRESSION_NEQUAL_RIGHT); m_parents.Pop(); return(0); }
public override int VisitExpr_DIVMULT(MINICParser.Expr_DIVMULTContext context) { ASTComposite m_parent = m_parents.Peek(); if (context.op.Type == MINICParser.MULT) { CASTExpressionMultiplication newnode = new CASTExpressionMultiplication(context.GetText(), m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(0), m_parentContext, contextType.CT_EXPRESSION_MULTIPLICATION_LEFT); this.VisitElementInContext(context.expression(1), m_parentContext, contextType.CT_EXPRESSION_MULTIPLICATION_RIGHT); } else if (context.op.Type == MINICParser.DIV) { CASTExpressionDivision newnode = new CASTExpressionDivision(context.GetText(), m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(0), m_parentContext, contextType.CT_EXPRESSION_DIVISION_LEFT); this.VisitElementInContext(context.expression(1), m_parentContext, contextType.CT_EXPRESSION_DIVISION_RIGHT); } m_parents.Pop(); return(0); }
public override int VisitFunctionDefinition(MINICParser.FunctionDefinitionContext context) { ASTComposite m_parent = m_parents.Peek(); CASTFunctionDefinition newnode = new CASTFunctionDefinition(context.GetText(), m_parents.Peek(), 3); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitTerminalInContext(context, context.IDENTIFIER().Symbol, m_parentContext, contextType.CT_FUNCTIONDEFINITION_IDENTIFIER); if (context.fargs() != null) { this.VisitElementInContext(context.fargs(), m_parentContext, contextType.CT_FUNCTIONDEFINITION_FARGS); } this.VisitElementInContext(context.compoundStatement(), m_parentContext, contextType.CT_FUNCTIONDEFINITION_BODY); m_parents.Pop(); return(0); }
public override int VisitIfstatement(MINICParser.IfstatementContext context) { ASTComposite m_parent = m_parents.Peek(); CASTIfStatement newnode = new CASTIfStatement(context.GetText(), m_parents.Peek(), 3); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expression(), m_parentContext, contextType.CT_IFSTATEMENT_CONDITION); this.VisitElementInContext(context.statement(0), m_parentContext, contextType.CT_IFSTATEMENT_IFCLAUSE); if (context.statement(1) != null) { this.VisitElementInContext(context.statement(1), m_parentContext, contextType.CT_IFSTATEMENT_ELSECLAUSE); } m_parents.Pop(); return(0); }