Expressions Components - SICP Comparison Edition" /> 4.1.2   Representing <span style="color:green">Expressions</span> <span style="color:blue">Components</span> - SICP Comparison Edition
 Original JavaScript Programmers write programs as text, i.e. sequences of characters, entered in a programming environment or a text editor. To run our evaluator, we need to start with a representation of this program text as a JavaScript value. In section 2.3.1 we introduced strings to represent text. We would like to evaluate programs such as "const size = 2; 5 * size;" from section 1.1.2. Unfortunately, such program text does not provide enough structure to the evaluator. In this example, the program parts "size = 2" and "5 * size" look similar, but carry very different meanings. Abstract syntax functions such as declaration_value_expression would be difficult and error-prone to implement by examining the program text. In this section, we therefore introduce a function parse that translates program text to a tagged-list representation, reminiscent of the tagged data of section 2.4.2. For example, the application of parse to the program string above produces a data structure that reflects the structure of the program: a sequence consisting of a constant declaration associating the name size with the value 2 and a multiplication. parse("const size = 2; 5 * size;"); list("sequence", list(list("constant_declaration", list("name", "size"), list("literal", 2)), list("binary_operator_combination", "*", list("literal", 5), list("name", "size")))) The syntax functions used by the evaluator access the tagged-list representation produced by parse.
 Original JavaScript Figure 4.3 Syntax abstraction in the evaluator. Figure 4.3 depicts the abstraction barrier formed by the syntax predicates and selectors, which interface the evaluator to the tagged-list representation of programs, which in turn is separated from the string representation by parse. Below we describe the parsing of program components and list the corresponding syntax predicates and selectors, as well as constructors if they are needed.
Original JavaScript
Original JavaScript
 Original JavaScript Exercise 4.9 Let expressions are derived expressions, because (let ((var$_{1}$ exp$_{1}$) $\ldots$ (var$_{n}$ exp$_{n}$)) body) is equivalent to ((lambda (var$_{1}$ $\ldots$ var$_{n}$) body) exp$_{1}$ $\vdots$ exp$_{n}$) Implement a syntactic transformation let->combination that reduces evaluating let expressions to evaluating combinations of the type shown above, and add the appropriate clause to eval to handle let expressions. There is currently no solution available for this exercise. This textbook adaptation is a community effort. Do consider contributing by providing a solution for this exercise, using a Pull Request in Github.