I too am looking into creating a simple scripting language, but at the moment I've just been working on syntax for a configuration file (which I'm treating as a subset of the scripting language). Personally I like the use of braces and the semicolon as it keeps things "in the C family" so-to-speak and it's just something I'm used to.
Plus using if-endif is too BASIC-like...uh, I mean "wordy" for me

You can think of my configuration file format as a script that is limited to variable creation and assignment only. Later, I will expand it into a full-featured language as needed.
We start with five types of properties/variables: bool, int, real, string and composite. In the interest of getting some feedback in the same vein as irbrian, here is an example:
// Both C++ /* and C-style comments are allowed*/Title = "title1.jpg"; // stringAutoSaveOn = ShowTitleScreen = true; // multiple assignment okPlayer { // this is a composite property/variable named "Player" MaxHealth = 40; // int XPosition = 0.0; // real YPosition = 0.0; ZPosition = 0.0; Name = "Jeff"; Backpack { // composite within composite allowed Color = "Brown"; MaxItems = 10; }}
I have done away with using a "DIM" or "var" keyword as I, too, feel it is superfluous. I have also made each property/variable a sort-of variant type that can be re-assigned a different type (i.e. if you later did AutoSaveOn = "false", it would be turned into a string property).
I have already written the BNF for the above format (the hardest part was getting the string description correct for escape codes). I have already coded up a parser using boost::spirit (very cool, btw!). Now I'm just working on the wrapping class that takes the parsed symbols and creates the above structure in code...
I'm wondering if I need an array type? I like how PHP allows objects/composites to be viewed as arrays and vice-versa so I may do something similar down the line.
Regards,
Jeff
Edit: Fixed some typos
[ CodeDread ] [edited by - rypyr on April 14, 2004 3:37:05 PM]