Exemple #1
0
        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);
        }
Exemple #2
0
 private void Visit(StringLiteralExpr stringLiteral)
 {
     CurrentMethodIL.Emit(OpCodes.Ldstr, stringLiteral.Value);
 }
Exemple #3
0
 private void Visit(StringLiteralExpr stringLiteralExpr)
 {
     TypeStack.Push(TypeInfo.BasicString);
 }