Question: statements separated with ';' empty statement between consecutive';' is OK last statement can optionally followed by '; at least one space between all lexemes tab

statements separated with ';' empty statement between consecutive';' is OK last statement can optionally followed by '; at least one space between all lexemes tab and newline char are ignored variables: var name (identifier) consists of lower-letter only (no digits, spaces, punctuations) following words are reserved and can not be used as variable names: print, it, then examples of legal variables: x, y, apple, hello examples of illlegal variables: x4, Apple, hello world expressions : sums of positive integers and declared variables a variable must be declared and initialized in prior set_statement before it can be used in an expression example of legal expressions: 6, * + y, 3 + 45 + alpha example of illegal expressions : 3.2 - 7 2 * x + y three kinds of statements: set_stmt: varname exprn print stmt: print expen if stmt: if exprn > exprn then set_stmt output of execution of a program: print statements produce integer as a string) separated by one space the output should be trimmed so there is no leading and trailing spaces if the program contains an error, just return the string 'ERROR > 10 => 11 E> 3 ==> 20 ==> 17 57 52 ==> 4 60 30 Example outputs: Outputs are strings (no leading or trailing spaces, one space between numbers), example: the output 17 57 42 is actually '17 57 42' - 4 print w t - 10 ; print t C-11; print c ; vu - 22;:;vu = 3; print vu \t rd = 3; it 15 > 26 then rd = 28; ; print rd; y = 7;if 19 > 5 then y = 20; print y r = 17 ; K= 0 + 7 + 28; print r;kartk; print k + 5;print k h = 4; hk = 3 + 23 + 0print h ; hk = h + hk : print hk + 30; print hk; tg = 4;if tg > 5 then tg - 9 +7; print tg ; * = 25; 11; print k; w=k+w; print w; bf - k + w + 20 + 8; print bf + k apple - 16; if apple > 20 then apple - 23 + 18;:;\t\t; print apple; y - 26 ; P - 19 + 8, if y>p then py; print p; - 13 ; yn - 7+ 1;-) + yn + 1; 11 1 + yn yn + othen o = 1 + yn + o ; print o; nt = 26 ; x = 22 + nt ; n = nt + + 1; if nt + xc > XC + n then n = x + nt; print nt;:;print n py = 4 + 4 + 22 + 23 + 22; fd = 8 + py + 11 + 13; gv = 25 + py + fd + 18; if py + fd > gv then fd = PY + PY: print py + fd; if py > Ed then gv - fd; print fd + gv ; iq - 20 + 23 + 10 + 23 + 8;dg - 14 + iq + 10 + 24;1 - 6 + ig + dg + 4; if iq + dg > 1 then dg - iq + iq; > 25 36 114 --> 16 > 27 => 34 ==> 26 75 --> 182 332 class H04: def __init__(self): pass def exec(sell, prog) return ERROR may user may not use: st) int() strip) try-catch split() dictionary det play (prog): h4 - H04) out - h4.exec(prog) print(" (prog) - In fout) play print 45 player print 3; print 5:) play('print 1+2+3 play alpha-1beta-2 gams - alphabetas play alpha - 1 beta - 2; print alpha; gamma alphabets:") play('* - 15 print x 30') play(x - 15:40: print x + 100) play('* - 10; y - x 40; print x.' play("hello - 123, world - 7000: print hello world') play apple - 3 orange print apple cherry - apple range + apple: print cherry playi'a 13 print a; b. 2: print b In print & play - 4*-*. 3: Y-**** print y print x play('* - 4, it > 7 then x - 300; print x) play - 4; if > 2 then - 500: print ') the following should returns ERROR play('print x') play - 4* - 2 + y ) play("if - then prints play(-3.57 print *') sample output print 45 45 print 3print 51 print 1.2.3 alpha - 1; beta - 2; gamma - slpha + beta alpha - 1; beta - 2; print alpha; gamma - alpha + beta; -1; print statements separated with ';' empty statement between consecutive';' is OK last statement can optionally followed by '; at least one space between all lexemes tab and newline char are ignored variables: var name (identifier) consists of lower-letter only (no digits, spaces, punctuations) following words are reserved and can not be used as variable names: print, it, then examples of legal variables: x, y, apple, hello examples of illlegal variables: x4, Apple, hello world expressions : sums of positive integers and declared variables a variable must be declared and initialized in prior set_statement before it can be used in an expression example of legal expressions: 6, * + y, 3 + 45 + alpha example of illegal expressions : 3.2 - 7 2 * x + y three kinds of statements: set_stmt: varname exprn print stmt: print expen if stmt: if exprn > exprn then set_stmt output of execution of a program: print statements produce integer as a string) separated by one space the output should be trimmed so there is no leading and trailing spaces if the program contains an error, just return the string 'ERROR > 10 => 11 E> 3 ==> 20 ==> 17 57 52 ==> 4 60 30 Example outputs: Outputs are strings (no leading or trailing spaces, one space between numbers), example: the output 17 57 42 is actually '17 57 42' - 4 print w t - 10 ; print t C-11; print c ; vu - 22;:;vu = 3; print vu \t rd = 3; it 15 > 26 then rd = 28; ; print rd; y = 7;if 19 > 5 then y = 20; print y r = 17 ; K= 0 + 7 + 28; print r;kartk; print k + 5;print k h = 4; hk = 3 + 23 + 0print h ; hk = h + hk : print hk + 30; print hk; tg = 4;if tg > 5 then tg - 9 +7; print tg ; * = 25; 11; print k; w=k+w; print w; bf - k + w + 20 + 8; print bf + k apple - 16; if apple > 20 then apple - 23 + 18;:;\t\t; print apple; y - 26 ; P - 19 + 8, if y>p then py; print p; - 13 ; yn - 7+ 1;-) + yn + 1; 11 1 + yn yn + othen o = 1 + yn + o ; print o; nt = 26 ; x = 22 + nt ; n = nt + + 1; if nt + xc > XC + n then n = x + nt; print nt;:;print n py = 4 + 4 + 22 + 23 + 22; fd = 8 + py + 11 + 13; gv = 25 + py + fd + 18; if py + fd > gv then fd = PY + PY: print py + fd; if py > Ed then gv - fd; print fd + gv ; iq - 20 + 23 + 10 + 23 + 8;dg - 14 + iq + 10 + 24;1 - 6 + ig + dg + 4; if iq + dg > 1 then dg - iq + iq; > 25 36 114 --> 16 > 27 => 34 ==> 26 75 --> 182 332 class H04: def __init__(self): pass def exec(sell, prog) return ERROR may user may not use: st) int() strip) try-catch split() dictionary det play (prog): h4 - H04) out - h4.exec(prog) print(" (prog) - In fout) play print 45 player print 3; print 5:) play('print 1+2+3 play alpha-1beta-2 gams - alphabetas play alpha - 1 beta - 2; print alpha; gamma alphabets:") play('* - 15 print x 30') play(x - 15:40: print x + 100) play('* - 10; y - x 40; print x.' play("hello - 123, world - 7000: print hello world') play apple - 3 orange print apple cherry - apple range + apple: print cherry playi'a 13 print a; b. 2: print b In print & play - 4*-*. 3: Y-**** print y print x play('* - 4, it > 7 then x - 300; print x) play - 4; if > 2 then - 500: print ') the following should returns ERROR play('print x') play - 4* - 2 + y ) play("if - then prints play(-3.57 print *') sample output print 45 45 print 3print 51 print 1.2.3 alpha - 1; beta - 2; gamma - slpha + beta alpha - 1; beta - 2; print alpha; gamma - alpha + beta; -1; print
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
