Write a program in scheme that can change a mixed simple list according to the following formula

computer science

Description

Question 1: Use the following grammar to answer related questions:

                       

            cf à head st end | head st

            head à repeat | while (cond) | if (cond) | for(assign; cond; assign) | else st

            end à until(cond) | do | endfor | endif | end

                        st à cf | expr | st st | assign

                        expr à var + expr | var – expr | var * expr | var /expr | var | (expr)

                        assign à var = expr; | var = expr

                        var à a |b |c |d…x|z| varvar| const

                        const à - ∞ …-1|0|1…∞                                            (all numbers)

cond à expr rop expr | cond rop cond | (cond) | rop (cond)

rop à > | < | = | != | AND | OR | NOT

 

Have a left-most derivation and show a parse-tree for the following statement                        (5 Marks)

 

                              while (x < y)

 x = b+xy;

else

y = m + (a9/10)

do                                                      

 

Question 2: Write a program in scheme that can change a mixed simple list according to the following formula. (5 Marks)

 

·         Replace any number to hexadecimal

·         Replace any small letter to caps and vice versa

·         If the number of element is equal to L, then show half of the list else show the complete list.

 

Question 3: For the above problem write a program using an imperative or object oriented language except C/C++ and Java (5 Marks)


Related Questions in computer science category