Hi, welcome to the group!
I was confused about what level of expertise to pitch an answer at until I
finally worked out that you live in a part of the world where "college"
and
"university" aren't synonyms. :-)
The very best thing would be if you can dig up a copy of _Logo Works:
Challenging Programs in Logo_ (Solomon, Minsky, Harvey, eds., McGraw-Hill,
1986), because it includes a Logo interpreter written in Logo, which would
definitely help you understand the structure of an interpreter.
If I'm understanding your message correctly, one thing that's making it
hard
for you is that you're representing a Logo instruction as a character
string,
which has no structure beyond the individual characters. What you really
want
is to represent an instruction as something like a Logo list:
? make "instruction [repeat 4 [fd 100 rt 90]]
? print count :instruction
3
? print first :instruction
fd
? print last :instruction
fd 100 rt 90
? print first (last :instruction)
fd
I don't know what VB gives you in the way of data structures, but I hope
you
can achieve something at least roughly like this.
Then you want to write a procedure that can evaluate a single instruction
or expression. (An instruction is something like
print count :instruction
that takes an action; an expression is something like
count :instruction
that outputs a value.) This EVAL procedure has to handle special cases
such
as numbers (just return the number itself), quoted words (return the word
without the initial quotation mark), etc. Otherwise, it's a procedure
call.
The first thing in a procedure call is the name of a procedure. You have
to
look up that name in a table of procedures, to find out how many inputs it
takes. Then call EVAL recursively that many times to get the input
values,
and then call the procedure itself.
Procedure calls inside repeats shouldn't be different from procedure calls
anywhere else, since you'll just EVAL the second input to REPEAT
repeatedly.
To call a user-defined procedure, you have to set up a table associating
the names of the inputs (from the procedure's title line) with the actual
input values (from the recursive EVAL calls), then just EVAL the body of
the procedure!
That may be too abstract for you -- maybe if you ask more specific
questions?


|