public override ASTNode VisitAddminus([NotNull] SuperCOOLParser.AddminusContext context)
        {
            if (context.ADD() != null)
            {
                var resultadd = new ASTAddNode()
                {
                };
                ASTExpressionNode leftadd = (ASTExpressionNode)context.expression()[0].Accept(this);
                AssignSymbolTable(leftadd);
                ASTExpressionNode rightadd = (ASTExpressionNode)context.expression()[1].Accept(this);
                AssignSymbolTable(rightadd);
                resultadd.Left     = leftadd;
                resultadd.Right    = rightadd;
                resultadd.AddToken = context.ADD().Symbol;
                return(resultadd);
            }
            var result = new ASTMinusNode()
            {
            };
            ASTExpressionNode left = (ASTExpressionNode)context.expression()[0].Accept(this);

            AssignSymbolTable(left);
            ASTExpressionNode right = (ASTExpressionNode)context.expression()[1].Accept(this);

            AssignSymbolTable(right);

            result.Left       = left;
            result.Right      = right;
            result.MinusToken = context.MINUS().Symbol;
            return(result);
        }
示例#2
0
        public override SemanticCheckResult VisitAdd(ASTAddNode Add)
        {
            var left  = Add.Left.Accept(this);
            var right = Add.Right.Accept(this);

            Add.SemanticCheckResult.Ensure(left, left.Type == CompilationUnit.TypeEnvironment.Int,
                                           new Lazy <Error>(() => new Error("Left Expresion must have type Int", ErrorKind.TypeError, Add.AddToken.Line, Add.AddToken.Column)));
            Add.SemanticCheckResult.Ensure(right, right.Type == CompilationUnit.TypeEnvironment.Int,
                                           new Lazy <Error>(() => new Error("Right Expresion must have type Int", ErrorKind.TypeError, Add.AddToken.Line, Add.AddToken.Column)));
            Add.SemanticCheckResult.EnsureReturnType(CompilationUnit.TypeEnvironment.Int);
            return(Add.SemanticCheckResult);
        }
示例#3
0
		public void AdditiveExpression()
		{
			MultiplicativeExpression();
			while(true)
			{
				switch(GetCurrentTokenKind())
				{
					case ParserConstants.MINUS:
					case ParserConstants.PLUS:
						;
						break;

					default:
						jj_la1[43] = jj_gen;
						//UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1012"'
						goto label_17_brk;
				}
				switch(GetCurrentTokenKind())
				{
					case ParserConstants.PLUS:
						ConsumeToken(ParserConstants.PLUS);
						ASTAddNode jjtn001 = new ASTAddNode(this, ParserTreeConstants.ADD_NODE);
						bool jjtc001 = true;
						nodeTree.OpenNodeScope(jjtn001);
						//UPGRADE_NOTE: Exception 'java.lang.Throwable' was converted to ' ' which has different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1100"'
						try
						{
							MultiplicativeExpression();
						}
						catch(Exception jjte001)
						{
							nodeTree.ClearNodeScope(jjtn001);
							jjtc001 = false;
							if (jjte001 is SystemException)
							{
								throw;
							}
							if (jjte001 is ParseException)
							{
								throw;
							}
							throw (ApplicationException) jjte001;
						}
						finally
						{
							if (jjtc001)
							{
								nodeTree.CloseNodeScope(jjtn001, 2);
							}
						}
						break;

					case ParserConstants.MINUS:
						ConsumeToken(ParserConstants.MINUS);
						ASTSubtractNode jjtn002 = new ASTSubtractNode(this, ParserTreeConstants.SUBTRACT_NODE);
						bool jjtc002 = true;
						nodeTree.OpenNodeScope(jjtn002);
						//UPGRADE_NOTE: Exception 'java.lang.Throwable' was converted to ' ' which has different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1100"'
						try
						{
							MultiplicativeExpression();
						}
						catch(Exception jjte002)
						{
							nodeTree.ClearNodeScope(jjtn002);
							jjtc002 = false;
							if (jjte002 is SystemException)
							{
								throw;
							}
							if (jjte002 is ParseException)
							{
								throw;
							}
							throw (ApplicationException) jjte002;
						}
						finally
						{
							if (jjtc002)
							{
								nodeTree.CloseNodeScope(jjtn002, 2);
							}
						}
						break;

					default:
						jj_la1[44] = jj_gen;
						ConsumeToken(-1);
						throw new ParseException();
				}
			}
			//UPGRADE_NOTE: Label 'label_17_brk' was added. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1011"'
			label_17_brk:
			;
		}
示例#4
0
 public virtual Object Visit(ASTAddNode node, Object data)
 {
     data = node.ChildrenAccept(this, data);
     return(data);
 }
示例#5
0
 /// <summary>Display an ASTAddNode ( + )
 /// </summary>
 public override Object Visit(ASTAddNode node, Object data)
 {
     return(ShowNode(node, data));
 }
示例#6
0
 public ASTCILNode VisitAdd(ASTAddNode Add)
 {
     return(new ASTCILAddTwoVariablesNode((ASTCILExpressionNode)Add.Left.Accept(this),
                                          (ASTCILExpressionNode)Add.Right.Accept(this)));
 }
示例#7
0
 /// <summary>Display an ASTAddNode ( + )
 /// </summary>
 public override System.Object visit(ASTAddNode node, System.Object data)
 {
     return(showNode(node, data));
 }
示例#8
0
 public virtual System.Object visit(ASTAddNode node, System.Object data)
 {
     data = node.childrenAccept(this, data);
     return(data);
 }
示例#9
0
 public override object Visit(ASTAddNode node, object data)
 {
     return(this.ShowNode(node, data));
 }
 public virtual T VisitAdd(ASTAddNode Add)
 {
     Add.Left.Accept(this);
     Add.Right.Accept(this);
     return(default(T));
 }