In the Pascal programming language, the
If-Statement
is defined as follows:
Consider the following statement, and then answer the related questions:
<If-Statement> ::= If <Condition> Then <Statement> [Else<Statement>] <Statement> ::= <If-Statement> | <While-Statement> | <For-Statement> | <Assignment-Statement>
<Condition> ::= [not] <Condition> | [not] <BooleanVariable> | <Variable> <Operator> Variable> |
<Variable> <Operator> <Expression> | < Expression > <Operator> <Variable> |
< Expression > <Operator> < Expression> | < Expression > <Operator> < Literal > |
<Variable> <Operator> < Literal >
<Operator> ::= = | < | <= | > | >= | <>
Consider the following statement, and then answer the related questions:
If C1 Then If C2 Then S1 Else S2
7a. Explain the phenomenon called ambiguity.
7b. Using derivation tree(s) or otherwise, show that the statement is ambiguous.
Draw a picture.
7c. This kind of ambiguity exists in C++ as well as Java. Explain and demonstrate how it can
be avoided by the programmer in these two languages.
In the Pascal programming language, the If-Statement is defined as follows: Consider the following statement, and...