예제 #1
0
 public override object Visit(ParenthesizedExpression parenthesizedExpression, object data)
 {
     if (parenthesizedExpression == null) {
         return null;
     }
     return parenthesizedExpression.Expression.AcceptVisitor(this, data);
 }
 public override object Visit(ParenthesizedExpression expression, object data)
 {
     return expression.Expression.AcceptVisitor(this, data);
 }
        public override object Visit(ParenthesizedExpression parenthesizedExpression, object data)
        {
            DebugOutput(parenthesizedExpression);
            string innerExpr = parenthesizedExpression.Expression.AcceptVisitor(this, data).ToString();

            // parenthesized cast expressions evaluate to a single 'method call' and don't need
            // to be parenthesized anymore like in C#. Parenthesized cast expresions may lead to
            // a vb.net compiler error (method calls)
            if (parenthesizedExpression.Expression is CastExpression) {
                return innerExpr;
            }
            return String.Concat("(", innerExpr, ")");
        }
 public override object Visit(ParenthesizedExpression expression, object data)
 {
     Console.WriteLine(expression.ToString());
     return expression.AcceptChildren(this, data);
 }
 public virtual object Visit(ParenthesizedExpression parenthesizedExpression, object data)
 {
     return parenthesizedExpression.Expression.AcceptVisitor(this, data);
 }
예제 #6
0
	void PrimaryExpr(
#line  1824 "cs.ATG" 
out Expression pexpr) {

#line  1826 "cs.ATG" 
		TypeReference type = null;
		bool isArrayCreation = false;
		Expression expr;
		pexpr = null;
		
		switch (la.kind) {
		case 112: {
			lexer.NextToken();

#line  1833 "cs.ATG" 
			pexpr = new PrimitiveExpression(true, "true");  
			break;
		}
		case 71: {
			lexer.NextToken();

#line  1834 "cs.ATG" 
			pexpr = new PrimitiveExpression(false, "false"); 
			break;
		}
		case 89: {
			lexer.NextToken();

#line  1835 "cs.ATG" 
			pexpr = new PrimitiveExpression(null, "null");  
			break;
		}
		case 2: {
			lexer.NextToken();

#line  1836 "cs.ATG" 
			pexpr = new PrimitiveExpression(t.literalValue, t.val);  
			break;
		}
		case 1: {
			lexer.NextToken();

#line  1838 "cs.ATG" 
			pexpr = new IdentifierExpression(t.val); 
			break;
		}
		case 18: {
			lexer.NextToken();
			Expr(
#line  1840 "cs.ATG" 
out expr);
			Expect(19);

#line  1840 "cs.ATG" 
			pexpr = new ParenthesizedExpression(expr); 
			break;
		}
		case 51: case 53: case 56: case 61: case 65: case 74: case 81: case 86: case 90: case 101: case 103: case 107: case 115: case 116: case 119: {
			switch (la.kind) {
			case 51: {
				lexer.NextToken();
				break;
			}
			case 53: {
				lexer.NextToken();
				break;
			}
			case 56: {
				lexer.NextToken();
				break;
			}
			case 61: {
				lexer.NextToken();
				break;
			}
			case 65: {
				lexer.NextToken();
				break;
			}
			case 74: {
				lexer.NextToken();
				break;
			}
			case 81: {
				lexer.NextToken();
				break;
			}
			case 86: {
				lexer.NextToken();
				break;
			}
			case 90: {
				lexer.NextToken();
				break;
			}
			case 101: {
				lexer.NextToken();
				break;
			}
			case 103: {
				lexer.NextToken();
				break;
			}
			case 107: {
				lexer.NextToken();
				break;
			}
			case 115: {
				lexer.NextToken();
				break;
			}
			case 116: {
				lexer.NextToken();
				break;
			}
			case 119: {
				lexer.NextToken();
				break;
			}
			}

#line  1846 "cs.ATG" 
			string val = t.val; t.val = ""; 
			Expect(13);
			Expect(1);

#line  1846 "cs.ATG" 
			pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); 
			break;
		}
		case 110: {
			lexer.NextToken();

#line  1848 "cs.ATG" 
			pexpr = new ThisReferenceExpression(); 
			break;
		}
		case 50: {
			lexer.NextToken();

#line  1850 "cs.ATG" 
			Expression retExpr = new BaseReferenceExpression(); 
			if (la.kind == 13) {
				lexer.NextToken();
				Expect(1);

#line  1852 "cs.ATG" 
				retExpr = new FieldReferenceExpression(retExpr, t.val); 
			} else if (la.kind == 16) {
				lexer.NextToken();
				Expr(
#line  1853 "cs.ATG" 
out expr);

#line  1853 "cs.ATG" 
				ArrayList indices = new ArrayList(); indices.Add(expr); 
				while (la.kind == 12) {
					lexer.NextToken();
					Expr(
#line  1854 "cs.ATG" 
out expr);

#line  1854 "cs.ATG" 
					indices.Add(expr); 
				}
				Expect(17);

#line  1855 "cs.ATG" 
				retExpr = new IndexerExpression(retExpr, indices); 
			} else SynErr(179);

#line  1856 "cs.ATG" 
			pexpr = retExpr; 
			break;
		}
		case 88: {
			lexer.NextToken();
			NonArrayType(
#line  1857 "cs.ATG" 
out type);

#line  1857 "cs.ATG" 
			ArrayList parameters = new ArrayList(); 
			if (la.kind == 18) {
				lexer.NextToken();

#line  1862 "cs.ATG" 
				ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); 
				if (StartOf(21)) {
					Argument(
#line  1862 "cs.ATG" 
out expr);

#line  1862 "cs.ATG" 
					parameters.Add(expr); 
					while (la.kind == 12) {
						lexer.NextToken();
						Argument(
#line  1863 "cs.ATG" 
out expr);

#line  1863 "cs.ATG" 
						parameters.Add(expr); 
					}
				}
				Expect(19);

#line  1863 "cs.ATG" 
				pexpr = oce; 
			} else if (la.kind == 16) {

#line  1865 "cs.ATG" 
				isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; 
				lexer.NextToken();

#line  1866 "cs.ATG" 
				int dims = 0; ArrayList rank = new ArrayList(); ArrayList parameterExpression = new ArrayList(); 
				if (StartOf(4)) {
					Expr(
#line  1868 "cs.ATG" 
out expr);

#line  1868 "cs.ATG" 
					parameterExpression.Add(expr); 
					while (la.kind == 12) {
						lexer.NextToken();
						Expr(
#line  1868 "cs.ATG" 
out expr);

#line  1868 "cs.ATG" 
						parameterExpression.Add(expr); 
					}
					Expect(17);

#line  1868 "cs.ATG" 
					parameters.Add(new ArrayCreationParameter(parameterExpression)); ace.Parameters = parameters; 
					while (
#line  1869 "cs.ATG" 
IsDims()) {
						Expect(16);

#line  1869 "cs.ATG" 
						dims =0;
						while (la.kind == 12) {
							lexer.NextToken();

#line  1869 "cs.ATG" 
							dims++;
						}

#line  1869 "cs.ATG" 
						rank.Add(dims); parameters.Add(new ArrayCreationParameter(dims)); 
						Expect(17);
					}

#line  1870 "cs.ATG" 
					if (rank.Count > 0) { ace.Rank = (int[])rank.ToArray(typeof (int)); } 
					if (la.kind == 14) {
						ArrayInitializer(
#line  1871 "cs.ATG" 
out expr);

#line  1871 "cs.ATG" 
						ace.ArrayInitializer = (ArrayInitializerExpression)expr; 
					}
				} else if (la.kind == 12 || la.kind == 17) {
					while (la.kind == 12) {
						lexer.NextToken();

#line  1873 "cs.ATG" 
						dims++;
					}

#line  1873 "cs.ATG" 
					parameters.Add(new ArrayCreationParameter(dims)); 
					Expect(17);
					while (
#line  1873 "cs.ATG" 
IsDims()) {
						Expect(16);

#line  1873 "cs.ATG" 
						dims =0;
						while (la.kind == 12) {
							lexer.NextToken();

#line  1873 "cs.ATG" 
							dims++;
						}

#line  1873 "cs.ATG" 
						parameters.Add(new ArrayCreationParameter(dims)); 
						Expect(17);
					}
					ArrayInitializer(
#line  1873 "cs.ATG" 
out expr);

#line  1873 "cs.ATG" 
					ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.Parameters = parameters; 
				} else SynErr(180);
			} else SynErr(181);
			break;
		}
		case 114: {
			lexer.NextToken();
			Expect(18);
			if (
#line  1879 "cs.ATG" 
NotVoidPointer()) {
				Expect(122);

#line  1879 "cs.ATG" 
				type = new TypeReference("void"); 
			} else if (StartOf(8)) {
				Type(
#line  1880 "cs.ATG" 
out type);
			} else SynErr(182);
			Expect(19);

#line  1881 "cs.ATG" 
			pexpr = new TypeOfExpression(type); 
			break;
		}
		case 104: {
			lexer.NextToken();
			Expect(18);
			Type(
#line  1882 "cs.ATG" 
out type);
			Expect(19);

#line  1882 "cs.ATG" 
			pexpr = new SizeOfExpression(type); 
			break;
		}
		case 57: {
			lexer.NextToken();
			Expect(18);
			Expr(
#line  1883 "cs.ATG" 
out expr);
			Expect(19);

#line  1883 "cs.ATG" 
			pexpr = new CheckedExpression(expr); 
			break;
		}
		case 117: {
			lexer.NextToken();
			Expect(18);
			Expr(
#line  1884 "cs.ATG" 
out expr);
			Expect(19);

#line  1884 "cs.ATG" 
			pexpr = new CheckedExpression(expr); 
			break;
		}
		default: SynErr(183); break;
		}
		while (StartOf(27)) {
			if (la.kind == 29 || la.kind == 30) {
				if (la.kind == 29) {
					lexer.NextToken();

#line  1888 "cs.ATG" 
					pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); 
				} else if (la.kind == 30) {
					lexer.NextToken();

#line  1889 "cs.ATG" 
					pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); 
				} else SynErr(184);
			} else if (la.kind == 47) {
				lexer.NextToken();
				Expect(1);

#line  1892 "cs.ATG" 
				pexpr = new PointerReferenceExpression(pexpr, t.val); 
			} else if (la.kind == 13) {
				lexer.NextToken();
				Expect(1);

#line  1893 "cs.ATG" 
				pexpr = new FieldReferenceExpression(pexpr, t.val);
			} else if (la.kind == 18) {
				lexer.NextToken();

#line  1895 "cs.ATG" 
				ArrayList parameters = new ArrayList(); 
				if (StartOf(21)) {
					Argument(
#line  1896 "cs.ATG" 
out expr);

#line  1896 "cs.ATG" 
					parameters.Add(expr); 
					while (la.kind == 12) {
						lexer.NextToken();
						Argument(
#line  1897 "cs.ATG" 
out expr);

#line  1897 "cs.ATG" 
						parameters.Add(expr); 
					}
				}
				Expect(19);

#line  1898 "cs.ATG" 
				pexpr = new InvocationExpression(pexpr, parameters); 
			} else {

#line  1900 "cs.ATG" 
				if (isArrayCreation) Error("element access not allow on array creation");
				ArrayList indices = new ArrayList();
				
				lexer.NextToken();
				Expr(
#line  1903 "cs.ATG" 
out expr);

#line  1903 "cs.ATG" 
				indices.Add(expr); 
				while (la.kind == 12) {
					lexer.NextToken();
					Expr(
#line  1904 "cs.ATG" 
out expr);

#line  1904 "cs.ATG" 
					indices.Add(expr); 
				}
				Expect(17);

#line  1905 "cs.ATG" 
				pexpr = new IndexerExpression(pexpr, indices); 
			}
		}
	}
 public override object Visit(ParenthesizedExpression parenthesizedExpression, object data)
 {
     outputFormatter.PrintToken(Tokens.OpenParenthesis);
     parenthesizedExpression.Expression.AcceptVisitor(this, data);
     outputFormatter.PrintToken(Tokens.CloseParenthesis);
     return null;
 }