answer this questions by Describing a Simple Language Using BNF for Task1 & 2 He
ID: 3748164 • Letter: A
Question
answer this questions by Describing a Simple Language Using BNF for Task1 & 2 Here is an infornal description of a sinple language. Statenents in the language are as follovst read a vite a read an integer fron stardard input dorico into tho variable a. can be any lower case letter write the valu6 oton standard output devic (whatevor it i5). can be any lover case letter Assign to the variable the value of the variable b. and b oan be any letter between a and Assign the value of 58 to the variable aaean be any letter betveen a and . 58 can be any single digit or maltiple digit integer Add 1 to acan be any lover ease letter Subtract 1 from . can bo any lower case letter If a 0, transfer eontrol to statenen1abeled with L. L ean be any letter between and 2-a ean be any iower ease letter Transfer control to statenent labeled with L.I ean be any letter betveen A and 2 Stop execution, program shoaldalvays end vith halt ifExplanation / Answer
TASK 1
Read a;
Read b;
L: a := a+1;
b := b-1;
x := a;
if b>0 goto L;
write a;
halt;
TASK 2
<statement> ::= <typespecification> <varDeclaration> <assignment-operator> <expression>
<typespecification> ::= char | short | int | long | float | double | string
<varDeclaration> ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | x | y | z
<assignment-operator> ::= =
<assignment statement> ::= <variable> = <expression>
<expression> ::= <expression> + <value> | <expression> - <value> | <value>
<value> ::= <digit> | <letter> | <number> | <word>
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<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"
<number> ::= <digit> + <digit> | <digit> - <digit> | <digit> * <digit> | <digit> / <digit>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.