Here is a BNF grammar for simple assignment statements in la

Here is a BNF grammar for simple assignment statements in language ABC. Assume we all agree on the meaning of symbol <integer> (i.e. you can treat it as a terminal symbol).

<assignment-stmt> ::=   <variable> = <arithmetic-expr>

<arithmetic-expr>   ::=   <term>

| <arithmetic-expr> + <term>

               | <arithmetic-expr> - <term>

<term>           ::=   <primary>

               | <term> * <primary>

               | <term> / <primary>

<primary>       ::=   <variable>

               | <integer>

               | ( <arithmetic-expr> )

<variable>       ::=   <identifier>

               | <identifier> [ <subscript-list> ]

<subscript-list>   ::=   <arithmetic-expr>

               | <subscript-list> , <arithmetic-expr>

<identifier>   ::=   A | B | C | D | E | … | X | Y | Z

Is the following a legal assignment statement in this language? Prove or disprove.


A[2] = B + 1 * (C – 3)

Solution

Start from here :

These steps proved that this is a legal assignment statement in this language.

Here is a BNF grammar for simple assignment statements in language ABC. Assume we all agree on the meaning of symbol <integer> (i.e. you can treat it as a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site