//------------------------------------------------------------ // コンストラクタ。 public EvaluateNode(IExpression aFirstExpr, FunctionCallExpression aFuncExpr) { mFirstExpr = aFirstExpr; mFirstNode = mFirstExpr.CreateEvaluateNode(); mFuncExpr = aFuncExpr; if (mFuncExpr.mSequenceExpr != null) { mSeqNode = mFuncExpr.mSequenceExpr.CreateEvaluateNode(); } }
//------------------------------------------------------------ /// <summary> /// NewExpression: /// "new" TypePath FunctionCallExpression /// </summary> /// <returns></returns> IExpression parseNewExpression() { // "new" Assert.Check(currentToken().Value == Token.Kind.KeyNew); nextToken(); // TypePath TypePath typePath = parseTypePath(); if (typePath == null) { return(null); } // FunctionCallExpression FunctionCallExpression funcCallExpr = parseFunctionCallExpression(); if (funcCallExpr == null) { return(null); } return(new NewExpression(typePath, funcCallExpr)); }
//------------------------------------------------------------ // コンストラクタ。 public NewExpression(TypePath aTypePath, FunctionCallExpression aFuncCallExpr) { mTypePath = aTypePath; mFuncCallExpr = aFuncCallExpr; }
//------------------------------------------------------------ /// <summary> /// PostfixExpression: /// PrimaryExpression (PostfixOperator)* /// /// PostfixOperator: /// "++" /// | "--" /// | IndexExpression /// | FunctionCallExpression /// | "." Identifier # ChildIdentExpression /// </summary> /// <returns></returns> IExpression parsePostfixExpression() { IExpression firstExpr = parsePrimaryExpression(); while (firstExpr != null) { PostfixExpression.OpKind opKind = PostfixExpression.OpKind.Unknown; // OpTokenがある式 Token opToken = currentToken(); if (currentToken().Value == Token.Kind.OpPlusPlus) {// "++" opKind = PostfixExpression.OpKind.Inc; nextToken(); } else if (currentToken().Value == Token.Kind.OpMinusMinus) {// "--" opKind = PostfixExpression.OpKind.Dec; nextToken(); } if (opKind != PostfixExpression.OpKind.Unknown) { firstExpr = new PostfixExpression(opToken, opKind, firstExpr); } // OpTokenがない式 if (currentToken().Value == Token.Kind.OpLBracket) {// IndexExpression IndexExpression expr = parseIndexExpression(); if (expr == null) { return(null); } return(new PostfixExpression(firstExpr, expr)); } else if (currentToken().Value == Token.Kind.OpLParen) {// FunctionCallExpression FunctionCallExpression expr = parseFunctionCallExpression(); if (expr == null) { return(null); } return(new PostfixExpression(firstExpr, expr)); } else if (currentToken().Value == Token.Kind.OpDot) {// ChildIdentExpression nextToken(); if (currentToken().Value != Token.Kind.Identifier) { setErrorKind(ErrorKind.POSTFIX_EXPRESSION_IDENTIFIER_EXPECTED); return(null); } ChildIdentExpression expr = new ChildIdentExpression(new Identifier(currentToken())); nextToken(); return(new PostfixExpression(firstExpr, expr)); } else { return(firstExpr); } } return(firstExpr); }
//------------------------------------------------------------ // FunctionCallのコンストラクタ。 public PostfixExpression(IExpression aFirstExpr, FunctionCallExpression aFuncCallExpr) { mExprKind = ExprKind.FunctionCallExpr; mFirstExpr = aFirstExpr; mFunctionCallExpr = aFuncCallExpr; }