Following is an example of input statement in C subscripts c

Following is an example of input statement in C++ (subscripts can be expressions): Write a BNF definition of the syntax of (all possible) input statements in C++.

Solution

<cin statement> ::= cin >> <input sequences> ;

<input sequences> ::= <input item> | <input sequences> >> <input item>

<input item|> ::= <id>| <character> |<equation>|<function> |<id>[<id>] | *id

<id> ::= <letter>|<id><character>

<character>::= <digit>|<letter>

<number>::=<fraction>|<integer>

<fraction>::= <integer>.<integer>

<integer>::=<digit>|<integer><digit>

<equation>::=<operand><operation><operand>

<operation>::= +|-|*|/

<operand>::=<id>|<array>|<number>

<array>::=<id>[<unsigned integer>]|<id>[<unsigned integer>][<unsigned integer>]

< unsigned integer> ::= <digit> | <unsigned integer> <digit>

<function>::=<id>(<argument sequences>)

<argument sequences>::=<empty>|<argument>|<argument sequences>, <argument>

<relation operation>::=(<operand> <logic operation> <operand>)

<empty>::=

<letter> ::=         a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|

                             J|K|L|M|N|O|P| Q|R|S|T|U|V|W|X|Y|Z

<digit> ::= 1|2|3|4|5|6|7|8|9|0

 Following is an example of input statement in C++ (subscripts can be expressions): Write a BNF definition of the syntax of (all possible) input statements in C

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site