EXERCISES

  1. Some languages distinguish between keywords and reserved words. Suppose we want to allow a keyword as an identifier under some circumstances, how can it be done?
  2. We have a variable declaration statement int a, available in the simple language. Will it not be better to have a declaration plus initialization like int a 15 which will not only reserve space for variable ‘a’ but also initialize it to a value 15? What changes are required in the grammar, Scanner, parser and code generation to implement this?
  3. The if statement has rather limited power, as no relational operators are available in simple. Suggest a set of relational operators to be included in simple and investigate what modifications are required in various phases of the compiler to implement them.
  4. How would you include array variables in simple? Discuss how to use various addressing modes available in VM1 to implement arrays. You will need to enhance grammar, Scanner, parser and codegen also.
  5. Suppose you are told to include subroutine facility in simple language. Investigate if you can do this with just the instruction set given. Would you like to have some additional instructions?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.75.221