Exercise 4.10. By using data abstraction, we were able to write an eval procedure that is independent of the particular syntax of the language to be evaluated. To illustrate this, design and implement a new syntax for Scheme by modifying the procedures in this section, without changing eval or apply. ———————————————————————————————————————————————————————————————————————— The syntax can use no parentheses internally, just one list per program, with keywords used for function application, special forms, and so on, as in ALGOL-like languages. Because the semicolon is used to begin a comment in Scheme, we will use the letter j, which looks a little like a semicolon, in its place. Parentheses can be used for grouping. When the interpreter encounters a list as one of the terms of a program, it treats it as a parenthesised expression. Example program in Scheme: (define (factorial n) (if (= n 1) 1 (* (factorial (- n 1)) n))) (display (factorial 7)) And in the new syntax: (program define factorial n j if 1 = n j 1 j n * factorial (n - 1) j end display factorial 7 j ) The implementation of this syntax is more work than I want to do, but I will describe a possible approach. The evaluator is provided a list which begins with the symbol 'program. It first breaks the list into statements, separated by the symbol j. It then makes a pass over this list to group statements into higher-level constructs. Infix operators such as "=" and "+" consume one expression to either side. For special forms such as if, a specific number of substatements are consumed and grouped under the if. Other special forms such as define use specific tokens (in this case 'end') to mark the end of the special form. Once the list is broken up into statements and the statements are grouped, evaluation proceeds as normal. The symbols used to serve a syntactic purpose, such as program, end, and j, are reserved and cannot be used as variable names in the program, so not every Scheme program can be transformed directly into this syntax unless some variables are first renamed.