Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 955557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:23:57+00:00 2026-05-16T00:23:57+00:00

Sometimes back I was trying the following statement in C# i+++++i // does not

  • 0

Sometimes back I was trying the following statement in C#

i+++++i // does not compile <bt>

i++ + ++i // executed

Does space has impact in expressions?
In what way the above statements are different?

Ramachandran

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:23:57+00:00Added an answer on May 16, 2026 at 12:23 am

    First off, let me explain how a compiler works.

    The first thing we do is break up the source code into tokens. Then we organize the tokens into a parse tree. Then we do a semantic analysis of the parse tree, and then we generate code based on that semantic analysis. Any of those stages – lexing, parsing or analyzing – can produce errors. Here’s the important part: we do not go back and re-do a previous stage if a later stage got an error.

    The lexer is “greedy” – it attempts to make the biggest token it can at every stage of the way. So Daniel is right. The lexer breaks i+++++i up into i / ++ / ++ / + / i

    Then the parser tries to turn that into a parse tree and it comes up with

                    +
                   / \
                  ++  i
                 /
                ++
               /
              i   
    

    That is, equivalent to (((i++)++) + i).

    Now the semantic analyzer looks at that and says “i++ is fine because i is a variable. But i++ is not a variable, it’s a value. You cannot do ++ on a value, so the second ++ is illegal.” The semantic analyzer then gives the error: the operand of an increment must be a variable.

    The semantic analyzer does not then re-do the lex and say you know, this could have been i / ++ / + / ++ / i, which would parse differently and be legal. We don’t backtrack because there could be billions of possible ways to re-lex and re-parse a program and we don’t want to have to try all of them. Just consider your case; i+++++i could be (((i++)++)+i) or )((i++)+(+(+i))) or (i+(+(+(+(+i)))) or… remember, + can be part of a unary plus, binary plus, pre-increment or post-increment, and therefore there are a lot of possible combinations for these five plusses.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.