Archive for category SICP
‘Structure and Interpretation of Computer Programs’ (also known as the ‘Wizard’ book), I went through the concept of ‘Metacircular Evaluator ‘ in the fourth chapter of the book ,where a ‘language interpreter’ for lisp is implemented and language used for
- A complex procedure is evaluated by splitting it up into simpler subexpression which can be evaluated and the value is applied to the operand subexpression.
- 2) A compound or user defined procedure is evalauted in a new environment, which can be created by extending the current environment by adding a frame.
The Core of the Evaluator
The two main procedures in the evaluation processs are ‘eval‘ and ‘apply’ .
- ‘eval’ procedure is responsible for evaluating an expression in it’s environment. This procedure takes the expression and the environment as input parameters. It is this function where the determination of type of expression is done and the corresponding action is invoked.
- ‘apply’ procedure takes the operation and the parameters as the input and it applies the operation to it. This procedure diffrentiates between a primitive procedure to apply the primitives and a compound procedure , the body of whose is evaluated sequentially.
My B.tech major project was to implement a ‘Scheme-to-Python Compiler for Android’ where the language used was Scheme (a variant of lisp ).The project aimed at developing a compiler which would translate application program written in Scheme to Python which in turn can be run on Android platform. Here I used the concept of ‘Meta-circular Evaluator’ from SICP (“Structure and Interpretation of Computer Program“ ) the ‘wizard book’, to recognize each expression and then ,instead of evaluating it, my program generated the corresponding the Python expression.
The Python program generated was stored in the SDcard of Android SDK.
Now for Python programs to be supported on Android platform, SL4A was to be installed on Android SDK . This platform enabled python generated program to be run on the SDK providing many of the API’s provided to a full-fledged Android applications . I demonstrated my project by using a “text-to-speech” API available to Python which would process the text message to generate the corresponding speech.
- The first button when pressed invokes the ‘DrScheme’ with the Scheme code in it.The code in scheme can be checked for correctness and run with it.
- The second button when pressed invokes the ‘Compiler code‘,proceeses the input scheme program and generates the correspoding python program.
- The third button when pressed invokes ‘IDLE’ ( a python IDE) for validating the generated python code.
- The fourth button with an icon of ‘Android’ copies the generated python code into the SDCard s(memory card) and starts the Android SDK.
The source code for the above project can be downloaded from my git hub => email@example.com:rohitnjan88/S-T-A.git
The application in Android SDK can be invoked by clicking on the SL4A icon in the menu.