"Check For Errors"

Archives Forums/Blitz3D SDK Programming/"Check For Errors"

_PJ_(Posted 2009) [#1]
Hi peeps, I hope this is okay to post ehre, I figured it may be the best place to start.

I'm wondering if it is possible (Well, I know it of course CAN be done, but can it be done from within Blitz maybe with userlibs or something) to check a .bb file to see if it will compile okay, no real error messaging is necessary, just a simple yes or no if it can compile.

Of course, I wouldn't want a whole compiler, because that would be a bit naughty, right? So Just something similar to the "check for Errors" menu option...

Naturally, this should require that Blitz is installed on the system and all that jazz :)


Warner(Posted 2009) [#2]
I don't think that is possible without writing partly a compiler. In the code archives, under miscelaneous, there is an example compiler that you could check out. It just handles a basic BASIC syntax, but it gives an impression of how that should work.
Basically, you read each word in the source that is separated by spaces. Then you make it lowercase and determine what type of 'token' it is:
-is it a command? ie:print
-is it a word, but not a command? Then it is an identifier (variable/function name)
-is it a value? ie: 1.424
-etc.
Only certain tokens are allowed to start a sentence with.
This first token determines what token may follow. If another type of token follows than expected, an error occurs.
However, what makes it more difficult is the usage of types, functions, and the ability to override functions or use the same name for a variable, a type and a function.
I think it is a huge task, and to be honest, I don't think this idea will work. Maybe you can work around this problem somehow. Have you looked at the blitzcc commandline parameters? I found a description here:
http://www.bettiesart.com/tc/ultrablitz/


_PJ_(Posted 2009) [#3]
Thanks for the reply, Warner - I hadnt notied because I don't generally check these forums, and I only posted the question here because I misunderstood what "Bltz3D SDK" was :)

Anyway, although Charruah gave me a good idea which certainly seems more feasible and easier to implement than checking the entire .bb doc with my own prog, I wanna say thanks for the Ultrablitz link! I'd never even ehard of that before!