New SpecBAS available - Procedures and Functions.
Go here:
http://www.zxspectrum4.net/forum/viewtopic.php?f=6&t=17
And get the latest if you're interested. I've added procedures and functions (DEF PROC and speccy-style DEF FN).
D.
http://www.zxspectrum4.net/forum/viewtopic.php?f=6&t=17
And get the latest if you're interested. I've added procedures and functions (DEF PROC and speccy-style DEF FN).
D.
Post edited by Dunny on
Comments
Can I ask your advice on something please Dunny?... I seem to have found myself in the predicament that after Chrimbo, if I'm well enough, that I'm gonna have to write a BASIC programming language myself.
I never thought I'd do anything so complex or silly, as I'm not really clever enough, but have to I do... so I had a bit read of Game Scripting Mastery as they have a chapter on writing a lexer, parser etc etc
I think the book said there were two main ways, top down or bottom up IIRC, what would you say would be 1/ easiest for me, 2/ generally the better approach?
anywayz, I'd appreciate any answer you could give me, as the thought of having to do this scares me a little, hehe :)
I didn't really read any books or owt, so I don't know what "top-down" or "bottom-up" are :)
Basically, Sinclair BASIC can be divided into two areas - Keywords and Parameters. I use a stack-based system for everything.
LET a=2*4 breaks down as [4, 2, *, a, VAR_ASSIGN] - which is a modified Reverse-polish-notation expression. Look up conversions from "infix" to "postfix" to get an idea of how this is done for expressions. Converting to RPN makes brackets redundant, and is very easy to interpret. The above expression becomes:
Add "4" to the Stack
Add "2" to the Stack
Take the top two items on the stack and multiply them, and replace them with the result.
Add the variable "a" to the stack
take the variable from the top of the stack, and assign the value at the top of the stack to that variable.
All very easy. You need two stacks, naturally - the queue of tokens to be interpreted, and the output stack used for calculations.
Keywords that take more than one parameter are simple too - PRINT for example. You just keep converting each expression and adding them to the stack. When you interpret, you just keep doing the calculations until you hit the PRINT token, at which point all the expressions are sitting on the calculation stack ready for you to PRINT one at a time.
You could have a gander at the SpecBAS source, but it can be very hard to follow - my commenting isn't great. It really is very simple though.
D.
D.
karingal?s right, you are far too modest, you?ve no idea what kind of cut down convoluted language I was gonna come up with as I couldn?t figure out how to work out this problem... anyways, good luck both with SpecOS and SpecBasic and I really hope you get your Pandora by Christmas by some flook of luck, this is my first post from mine as a mate brought his wifi router down and you?re in for such a treat ...
P.S, had mine for nearly six months so far and no problems so far so don?t go believing all the horror stories on gp32x.com ;)
P.P.S. 87 percent charge left, hotfix 4, new notaz wifi hack, wifi on, underclocked to 366 MHz, Fuse running in background and 12 hours 37 remaining battery life :D wait till you get yours dude
Get yerself into #spin (pm me for the channel key) on irc.coldfront.net when you're ready to start - I'm in there most of the time and there are others who can also help a lot. Most of my impetus to continue comes from their encouragement and their contribution of ideas.
Please, just ... stop that! It's too painful to read. Looking at the updates recently, even though mine should be in the next 100, I doubt I'll get it before February. Ah well, here's hoping :)
SpecBAS will be ported to Pandora sharpish when I get it! Coding games for the Panda in a heavily extended Sinclair BASIC? Heaven!
D.
I?m always fightened of othe peoples ideas, have always stayed away from online aticles for coding and tried to muddle along and achive something in my on simple nonestandard way and so most of time if someone says can you add this I?m like yes but it?ll take me 4 years to figure out what you?re on about and 2 years to figure out how to do it, lmao :D seriously had a look at your forum before and the suggestion nevermind the solutions are waay over my head, but I guess that?s what you mean by hitting spin :)
I figure you?ll get your Pandora first week of Jan, you?re soo close in line and things really do seem to be shaping up finally, really do hope at least another customers get their by Chrimbo though, be pshing it mind with Christmas post etc etc
Can?t wait till you get SpecBas onto Pandora, got my Amiga disks backed up to adfs recently and so have lots of stuff I could port :)
...?!!!...
SpecBAS is a large part of the reason I ordered mine... and thankfully the Windows version goes some way in holding back the withdrawal symptoms until me Pandora arrives...
;)
http://www.reallyquick.co.uk/specbas
Includes all the new updates - sound, procedures, functions and bugfixes.
D.