<postal-address> ::= <name-part> <street-address> <zip-part> <personal-part> ::= <name> | <initial> "." <name-part> ::= <personal-part> <last-name> [<jr-part>] <EOL> | <personal-part> <name-part> <street-address> ::= [<apt>] <house-num> <street-name> <EOL> <zip-part> ::= <town-name> "," <state-code> <ZIP-code> <EOL>
<assign> -> <id> = <expr>
<id> -> A | B | C
<expr> -> <ID> + <expr>
| <id> * <expr>
| (<expr>)
| <id>
A = B * (A + C)
<assign> -> <id> = <expr>
<id> -> A | B | C
<expr> -> <ID> + <term>
| <term>
<term> -> <term> * <factor>
| <factor>
<factor> -> (<expr>)
|<id>
FORTRAN treated blanks as completely insignificant in the body of a statement. This could sometimes be convenient, e.g., to make numbers and variable names more readable.Two Equivalent Forms
HIVAL = 14713678923
HI VAL = 14 713 678 923However, ignoring blanks can sometimes cause problems. For example, consider the looping statement:
DO 3 I = 1,3 Suppose this were mistakenly coded with a period instead of a comma.
Two Equivalent Forms DO 3 I = 1.3 DO3I = 1.3 The interpretation would be as a variable assignment.
Unfortunately, exactly this kind of error occurred in the control program for a Mariner spacecraft to Venus, resulting in its loss. (Annals of the History of Computing, 1984, 6(1), page 6).
<pop> ::= [ <bop> , <pop> ] | <bop>(a)What are the nonterminal symbols?
<bop> ::= <boop> | ( <pop> )
<boop> ::= x | y | z
<assign> -> <id> = <expr>
<id> -> A | B | C
S -> A B C
A -> aA | a
B -> bB | b
C -> cC | c
What is the shortest string that belongs to the grammar?
<S> -> <A> <B> <C>
<A> -> a <A> | a
<B> -> b <B> | b
<C> -> c <C> | c