Latest Uploads
Extraterre ... .0.1 (zip)

dantheman363

Monty Teas ... Screenie 1

steve_ancell

Santa Clau ... ed his bag

waroffice

manic_platdude.png

spinal

Tetris Clone

steve_ancell

Super blues bros.

spinal

Code Snippets > Misc ( Created 04 September 2010 | Last Edited 04 September 2010)

Simple stack-based interpreter by Tikihead | No Votes
Includes comments and example ''programs''
Written in
Blitz
I wrote this something like a year ago but ran into it today, so I thought I'd post it. Anyways this takes a string of basic commands arranged in postfix and runs it through a lexer and parser/interpreter. This bit of code handles some unary and binary operators, variables, input and output, and if/elseif/else statements.
Obviously it is an extremely slow/limited implementation but with a bit of work and playing around it can easily be made better.

For example...
  • Add more functions!
  • Use something other than a space to separate tokens so you can put spaces in string literals
  • Use the shunting yard algorithm or similar to allow the user to input regular infix algebra
  • Tokenize the program beforehand to speed things up
  • Get rid of every string except string literals to speed things up drastically

  • If you have any questions just ask.

    -->

    There are no comments for this entry.
    Latest Posts
    Sidewalk Skiing
    Jayenkai Sat 14:57
    Musical Tastes
    Dabz Sat 11:38
    FIRST!!!
    steve_ancell Sat 11:22
    Coder's Block
    Jayenkai Thu 09:01
    Consumer Lockout
    9572AD Thu 06:09
    Professor Oak, Honest!!
    spinal Wed 23:24
    Position in Mind
    steve_ancell Wed 20:11
    Sonic Adventure v0.x
    Jayenkai Wed 07:08
    Noel's Graduation
    waroffice Wed 02:55
    Monkey vs iOS tweaks
    spinal Tue 22:51
    More

    Latest Items
    News : Newsletter #176
    Jayenkai Sat 04:49
    News : Newsletter #175
    Dabz Tue 09:38
    Blog : Snow: More Material Junk
    Cower Sat 23:17
    Dev-Diary : Mutant Monty: Amstrad CPC to Windows conversion
    rockford Fri 13:14
    Techy : AppleTV
    Jayenkai Thu 09:40
    Blog : Graphviz
    steve_ancell Sat 14:17
    Pets : Top-Down Shadow Hack
    Jayenkai Tue 05:52
    Snippet : JNKrunch v1.0
    Jayenkai Sat 07:20
    News : Newsletter #173
    waroffice Fri 04:47
    Blog : Material Loading
    Cower Fri 02:08
    Pets : I Done Won A Thing
    shroom_monk Sun 11:31
    Pets : Repurposing A Lexer
    Cower Mon 22:06
    Bah : Feeling a Little Angry
    spinal Mon 11:26
    News : Newsletter #170
    Dabz Sat 00:34
    Showcase : sbfgen
    Cower Sat 16:57
    More

    Who's Online
    CodersRule
    Sat, at 18:37
    dna
    Sat, at 18:05
    Evil Roy Ferguson
    Sat, at 17:56
    Cower
    Sat, at 17:39
    9572AD
    Sat, at 17:07
    Jayenkai
    Sat, at 16:33
    shroom_monk
    Sat, at 16:29
    steve_ancell
    Sat, at 16:22
    HoboBen
    Sat, at 16:15
    Hotshot
    Sat, at 15:44
    Link to this page
    Site : Jayenkai 2006-Infinity |
    MudChat's origins, BBCode's former life, Image Scaler.