Code archives/Miscellaneous/blitz3D like syntax to c++
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Well this will make coding in c++ easier. Still not sure on how to make c++ dll's for expanding blitz3d, as that is the primary goal here. But for now it will translate the basic syntax of Blitz3D to c++. and will provide a good reference to what your code would look like in c++. It's about 90% complete, but it might not go any farther then that, as I'm stumped on some of blitz3d's type handling. I'm using Dev-C++ for testing the c++ code, I have not tested on other C++ compilers. So features: [PLEASE READ THE BELOW] regular c++ case sensitive for all commands(not really but just to be on the safe side make everything lowercase! ) and variables(this is a must - 'a' is not the same as 'A' in c++ variable naming as well as 'ab' <> 'Ab' <> 'aB' <> 'AB') c++ basic math is good '+=' '-=' '*=' '/=' '++' '--' To use more complex math functions use '#include <math.h>' at the begining of the '.ob' file. The syntax is about the same as blitz3d for most if not all c++ math functions, the only thing that is different is you need to have a return convention for them ie: ;blitz3D cos example a# = Cos(n) ;translator example local a# a = float cos(n) you can inline c++ code with: [cpp] // put c++ code here [cpp] ;this will also work [c++] // put c++ code here [c++] Limitations: No mulitiple lines of code on a single line outside a c++ code block not only is it bad coding its not translated corectly: x = 1:y = 2:z = 3:for i = 1 to 10:print x:next should be x = 1 y = 2 z = 3 for i = 1 to 10 print x next the local statement in blitz3D allows assigning values to variables. that is not true with this translator. local x=1,y=2,words$="what is a word?",flo#=1.2323201 should be local x%,y,words$,flo# x = 1 y=2 words= "what is a word?" flo =1.2323201 The translator only works within class/end class and function/ end function scope. so globals need to be declared in c++ syntax and outside of any function and class. int i; string k; float x; 'type / end type' works the same as 'class / end class' any field accesor like blitz3D's 'f\variable' is changed to 'f.variable' . Things I haven't figured out. Insert, after, before, first, last, for f.foo = each foo converting strings to integers/floats and vis versa. If I remember more limitations or uses I will list them: Please tell me of any bugs or features that should be added! test2.ob Translates to 'test2.cpp': The source (put this in the same folder that test2.ob is in): | |||||
... |
Comments
| ||
A lot of my coding practicve follows the requirements here, Hopefully I've kept to my own rules enough to give this a try :) I'm sure it could be really handy in some cases, though pure C++ could perhaps be a lot better than translated B3D stuff, at least this couyld get most of the groundwork done in any conversions! Thanks for sharing MusicianKooL! |
Code Archives Forum