Saturday 24 November 2012

LISP INTERPRETER






LISP is a programming language with unique features. It is conceptually interactive. Input com- mands are given one by one and the associated result values are typed-out. LISP is an applicative language, meaning that it consists mainly of functional application commands. Besides function ap- plication, there are forms of assignment commands and conditional commands written in functional form. In general, iteration is replaced by recursion.


The data values on which a LISP function may operate includes real numbers. Thus, an expression
like “1.5 + 2” is a LISP statement which means: type-out the result of applying + to the argu-
ments 1.5 and 2. In LISP, function application statements are always written in prefix form, e.g.
+(1.5, 2). Moreover, rather than writing f (x, y) to indicate the result of the function f applied
to the arguments x and y, we write (f x y ) in LISP, so (+ 1.5 2) is the LISP form for “1.5 + 2”.
Finally, functions in LISP are usually specified by identifier names rather than special symbols.
Thus the correct way to compute 1.5 + 2 in LISP is to enter the expression (PLUS 1.5 2), which will,
indeed, cause “3.5” to be typed out. An expression such as (PLUS 1.5 2) is called a function call
expression. LISP functions can also operate on lists of objects; indeed the name “LISP” is derived
from the phrase “LISt Processing”.

LISP is commonly implemented with an interpreter program called the LISP interpreter. This
program reads LISP expressions which are entered as input and evaluates them and types out
the results. I will describe how a particular LISP interpreter is constructed in javascript on the next blog post.

Before discussing about Interpreter construction, take a look on the basic two parts of an Interpreter :

(a) Parsing 
(b) Execution

Parsing : The parsing component takes an input program in the form of a sequence of characters, verifies it according to the syntactic rules of the language, and translates the program into an internal representation. In a simple interpreter the internal representation is a tree structure that closely mirrors the nested structure of statements or expressions in the program. In a language translator called a compiler, the internal representation is a sequence of instructions that can be directly executed by the computer.

Execution :The internal representation is then processed according to the semantic rules of the language, thereby carrying out the computation.

The Lisp Parser is implemented with the function parse. Execution is implemented with the function eval.

A list such with a special keyword in the first position is called special form in Scheme. Here we need six special forms and three syntactic constructors.



9. procedure call 



[Expecting Your Valuable Comments]
Thank You

No comments:

Post a Comment