BlitzC - A Blitz Syntax Alternative - Thoughts???

Blitz3D Forums/Blitz3D Programming/BlitzC - A Blitz Syntax Alternative - Thoughts???

I've written a sortof 'translator' for my own syntax for Blitz now. Basically, it takes code like:

float yourFunction( A#, B# )
     Return A*B;
}

C# = yourFunction( Rnd(1,200),Rnd(1,200) );

D# = C#;
for N% = 0 to 200
     D++;
}

// pseudo-C styled syntax

D# -= Rnd(64);
D# /= Rnd(64);
D# *= Rnd(32);
D# --;

Print D#;


;; NOPARSE
; NOPARSE areas are areas that do not get parsed by the translator

If D# > 0 Then
     Print "> 0"
Else
     Print "< 0"
EndIf

;; OPENPARSE

E% = Rand(4)
switch e
     case 0;
          print "case 0";
     case 1;
          print "case 1";
     case 2;
          print "case 2";
     case 3;
          print "case 3";
     case 4;
          print "case 4";
}


And it translates that code into (in all of my tests at least) working BlitzBasic code. It only parses files with the extension 'bc'. You can include files that won't be parsed by just including normal 'bb' files, but if you include a 'bc' file then it will be parsed accordingly unless you wrap the include instruction in the ;; NOPARSE/;; OPENPARSE tags.

So, operators like +=, -=, /=, *=, ==, !=, ++, --, etc. are useable, you have curly brackets, etc. Inside of strings, in order to make it less of a pain in the fingers to add quotes, you can also use \" to escape the character (I recall escape being the proper term).

I'm considering defining a language sheet which lets you customize what these operators are exactly, but right now they're all hard-coded.

Also, opening brackets aren't used because, basically, they don't need to be used in these cases.

It's really fun writing this thing, might even help some people- who knows.