The following syntax diagrams for a particular programming language show the syntax of: An assignment statement
Question:
The following syntax diagrams for a particular programming language show the syntax of:
– An assignment statement
– A variable
– An unsigned integer
– A letter
– An operator
– A digit.
a) The following assignment statements are invalid.
Give the reason in each case.
i) C2 = C3 + 123
ii) A3 := B1 – B2
iii) A32 := A2 * 7
b) Copy and complete the Backus-Naur Form (BNF) for the syntax diagrams shown. has been done for you.
c) The definition of is changed to allow:
– One or two letters and
– Zero, one or two digits.
Draw an updated version of the syntax diagram for .
d) The definition of is altered so that its syntax has replaced by .
A real is defined to be:
– At least one digit before a decimal point
– A decimal point
– At least one digit after a decimal point.
Give the BNF for the revised and .
Step by Step Answer:
Cambridge International AS & A Level Computer Science
ISBN: 9781510457591
1st Edition
Authors: David Watson, Helen Williams