private Expression ParseFactor() { Expression factor; if (CurrentToken.Type == TokenType.Identifier) { factor = ParseCallOrVarExpr(); } else if (Accept(TokenType.IntLiteral)) { factor = new IntLiteralExpr(AcceptedToken); } else if (Accept(TokenType.StringLiteral)) { factor = new StringLiteralExpr(AcceptedToken); } else if (Accept(TokenType.RealLiteral)) { factor = new RealLiteralExpr(AcceptedToken); } else if (Accept(TokenType.LParen)) { Expression expr = ParseExpression(); Match(TokenType.RParen); factor = expr; } else if (Accept(TokenType.OpNot)) { UnaryExpr expr = new UnaryExpr(AcceptedToken); expr.Op = Operator.Not; expr.Expr = ParseFactor(); factor = expr; } else { throw new Exception(string.Format("Expected a factor, {0} found", CurrentToken.Type)); } if (Accept(TokenType.OpDot)) { MemberAccessExpr expr = new MemberAccessExpr(AcceptedToken); expr.AccessedExpr = factor; expr.MemberId = ParseIdentifier(); return(expr); } return(factor); }
private void Visit(RealLiteralExpr realLiteral) { CurrentMethodIL.Emit(OpCodes.Ldc_R8, realLiteral.Value); ApplyExprSign(realLiteral); }
private void Visit(RealLiteralExpr realLiteralExpr) { TypeStack.Push(TypeInfo.BasicReal); }