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(IntLiteralExpr intLiteral) { CurrentMethodIL.Emit(OpCodes.Ldc_I4, intLiteral.Value); ApplyExprSign(intLiteral); }
private void Visit(IntLiteralExpr intLiteralExpr) { TypeStack.Push(TypeInfo.BasicInt); }