T
Thomas
Hello,
I am a CS student and I want to write simple lisp interpreter. The code
should be entierly in C. I don't want to use any compiler generators like
Bison or Yak, since wrinting this in raw C will give me more experience. I
wrote a simple lexer ( changes leksems into the streams of tokens). The Lisp
dialect I have to implement is not defined in any formal way, but I have a
description of how it should behave (say its a >>writen halformal
description which leads me to confusion <<). I ask for some tips, materials
or guidence. Oh and it should use some garbage collector, but I think this
should be implemented in the end. I suppose I need to define data
structures in a clear way. I don't give a description of that machine lisp
abstraction, since all are similar. The fragment of the descripion is this :
(...)Program in Ansi C an interpreter of Lisp dialect described above. It
should contain efective implementation of the associate list, agregeting
atoms linked with values by the pseudofunction define and using some simple
garbage collector algorithm (the cell is alive, if it is possilble to reach
it starting from the atom belonging to the association list. The symbolic
data constructed during interpreter run should be put in array dyn_mem
define for example like this:
======================================================================
#define MEMSIZE 1024
struct cell {
union data *left, *right;
};
union data {
int atom; /* when MSB == 1 */
struct cell *next; /* when MSB == 0 */
};
struct cell dyn_mem[MEMSIZE];
======================================================================
Notice that this structure doesn't have MSB, to add in the orginal MacArthy
lisp it was the redundant part of data register ( 36 -th bit or something),
suppose this trick wouldn't go by on a 386 .....
I am a CS student and I want to write simple lisp interpreter. The code
should be entierly in C. I don't want to use any compiler generators like
Bison or Yak, since wrinting this in raw C will give me more experience. I
wrote a simple lexer ( changes leksems into the streams of tokens). The Lisp
dialect I have to implement is not defined in any formal way, but I have a
description of how it should behave (say its a >>writen halformal
description which leads me to confusion <<). I ask for some tips, materials
or guidence. Oh and it should use some garbage collector, but I think this
should be implemented in the end. I suppose I need to define data
structures in a clear way. I don't give a description of that machine lisp
abstraction, since all are similar. The fragment of the descripion is this :
(...)Program in Ansi C an interpreter of Lisp dialect described above. It
should contain efective implementation of the associate list, agregeting
atoms linked with values by the pseudofunction define and using some simple
garbage collector algorithm (the cell is alive, if it is possilble to reach
it starting from the atom belonging to the association list. The symbolic
data constructed during interpreter run should be put in array dyn_mem
define for example like this:
======================================================================
#define MEMSIZE 1024
struct cell {
union data *left, *right;
};
union data {
int atom; /* when MSB == 1 */
struct cell *next; /* when MSB == 0 */
};
struct cell dyn_mem[MEMSIZE];
======================================================================
Notice that this structure doesn't have MSB, to add in the orginal MacArthy
lisp it was the redundant part of data register ( 36 -th bit or something),
suppose this trick wouldn't go by on a 386 .....