Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Very simple interpreter

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 1st Apr 2007 01:44
This is related to the thread in Geek Culture "making your own language?", and one of the main topics it bytecode.

This isn't exactly bytecode, because the codes arent in single bytes, because it's in string form, but it works it the same way.

Here you go. A description of what it does is given:


The "var" thing makes a new variable. "Push" adds something to a stack. "clear" will clear the stack. "op" will apply an operator such as + or - to the top two items of the stack. "let" will set the variable you give it to the top item of the stack. And "show" will just show what you give it.

MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 15th Apr 2007 18:55
This is very good Zotoaster. One of few solid examples of interpreter code in DBP.



A book? I hate book. Book is stupid.
(Formerly Yellow)
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 16th Apr 2007 04:43
Yes, very good zotoaster. Is this what you showed me on MSN?

Cheers,

-db


Albert Einstein believed that imagination is more important than knowledge.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 16th Apr 2007 17:53
I showed you alot of things on MSN, probably including this thing heheheheh

Thanks fo the comments anyway

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Apr 2007 18:53
Great snippet, the more understandable this stuff is at the outset the more chance of people adopting it. If people were to add their own internal array references then there's a lot that this could do, I find the more control I give to editors and scripting the better.


Good guy, Good guy, Wan...

Login to post a reply

Server time is: 2024-11-22 18:34:11
Your offset time is: 2024-11-22 18:34:11