Older Version
Newer Version
BillW
Jan 29, 2008
This is a completely standards-compliant implementation of the HQ9++ programming language. See [http://esoteric.voxelperfect.net/wiki/HQ9_Plus] and [http://esoteric.voxelperfect.net/wiki/HQ9_Plus_Plus] for syntax, etc. [[code]] 'main execution loop... type "exit<ENTER>" to exit print "HQ9++ Interepeter - by Bill W." print "type 'exit' (no quotes) then return to quit" print while (lower$(code$) <> "exit") input ">"; code$ gosub [runCode] wend end [runCode] 'iterate over each character in the program pos = 1 while (pos <= len(code$)) select case lower$(mid$(code$, pos, 1)) case "h" 'h command = print hello world print "Hello, World!" 'end case case "q" 'q command = print source code print code$ 'end case case "9" '9 command = print the lyrics to "99 Bottles of Beer on the Wall" gosub [99bottles] 'end case case "+" '+/++ command = increment the accumulator 'OO portion of ++ command isn't implemented yet 'this shouldn't have much bearing on program execution... I think if (mid$(code$, pos+1, 1) = "+") then accumulator = accumulator + 2 pos = pos + 1 else accumulator = accumulator + 1 end if 'end case end select pos = pos + 1 wend return [99bottles] 'print the lyrics to "99 Bottles of Beer on the Wall" for x = 99 to 1 step -1 print x; " bottle(s) of beer on the wall," print x; " bottle(s) of beer." print "Take one down, pass it around, " print (x-1); " bottle(s) of beer on the wall." print next x return [[code]]