BC_Programming
01-08-2009, 05:15 PM
had to put this somewhere-
After finally fixing a few show-stopping bugs in my expression evaluation library, I realized that I could actually use it as the engine for a Custom script language.
In it's first iteration, code such as this:
STORE(X,50);
BCSH@WriteLn("WRITTEN!" + X);
would output:
BASeCamp Commandline BCScript Interpreter.
Copyright 2008-2009 BASeCamp Corporation. All rights reserved.
WRITTEN!50
***Script terminated.***
Which is actually kind of a surprise to me even, since adding the Semicolon as a "statement separator" was a after-thought.
The question will inevitably arise, "what does this language have that VBS or JScript don't?"
quite simple.
intrinsic support for arrays and operations on them. For example, the engine let's you directly specify an array:
STORE(X,{1,2,3,4,5});
BCSH@WriteLn(X);
will store a five element array in X, and then display it. It will be displayed as "{1,2,3,4,5}", which is exactly the same as the way it was input. More amazing, Operations can be performed directly on the array that in other languages would require a loop to perform:
STORE(X,{1,2,3,4,5});
STORE(Y,{5,6,2,4,1});
STORE(Z,(X+Y)*(X-Y));
BCSH@WriteLn("Z=");
BCSH@WriteLn(X);
BCSH@WriteLn(Z);
the output- quite extensive. See, by default, the operations are not scalar on arrays, but rather iterative. For example, {1,2}*{3,4} will be another two elements array, but get this: both items will themselves be arrays, facilitating a matrix: {{1*3,1*4},{2*3,2*4}}
BASeCamp Commandline BCScript Interpreter.
Copyright 2008-2009 BASeCamp Corporation. All rights reserved.
"Z="
{1,2,3,4,5}
{{{{-24,-30,-6,-18,0},{-28,-35,-7,-21,0},{-12,-15,-3,-9,0},{-20,-25,-5,-15,0},{-
8,-10,-2,-6,0}},{{-18,-24,0,-12,6},{-21,-28,0,-14,7},{-9,-12,0,-6,3},{-15,-20,0,
-10,5},{-6,-8,0,-4,2}},{{-12,-18,6,-6,12},{-14,-21,7,-7,14},{-6,-9,3,-3,6},{-10,
-15,5,-5,10},{-4,-6,2,-2,4}},{{-6,-12,12,0,18},{-7,-14,14,0,21},{-3,-6,6,0,9},{-
5,-10,10,0,15},{-2,-4,4,0,6}},{{0,-6,18,6,24},{0,-7,21,7,28},{0,-3,9,3,12},{0,-5
,15,5,20},{0,-2,6,2,8}}},{{{-28,-35,-7,-21,0},{-32,-40,-8,-24,0},{-16,-20,-4,-12
,0},{-24,-30,-6,-18,0},{-12,-15,-3,-9,0}},{{-21,-28,0,-14,7},{-24,-32,0,-16,8},{
-12,-16,0,-8,4},{-18,-24,0,-12,6},{-9,-12,0,-6,3}},{{-14,-21,7,-7,14},{-16,-24,8
,-8,16},{-8,-12,4,-4,8},{-12,-18,6,-6,12},{-6,-9,3,-3,6}},{{-7,-14,14,0,21},{-8,
-16,16,0,24},{-4,-8,8,0,12},{-6,-12,12,0,18},{-3,-6,6,0,9}},{{0,-7,21,7,28},{0,-
8,24,8,32},{0,-4,12,4,16},{0,-6,18,6,24},{0,-3,9,3,12}}},{{{-32,-40,-8,-24,0},{-
36,-45,-9,-27,0},{-20,-25,-5,-15,0},{-28,-35,-7,-21,0},{-16,-20,-4,-12,0}},{{-24
,-32,0,-16,8},{-27,-36,0,-18,9},{-15,-20,0,-10,5},{-21,-28,0,-14,7},{-12,-16,0,-
8,4}},{{-16,-24,8,-8,16},{-18,-27,9,-9,18},{-10,-15,5,-5,10},{-14,-21,7,-7,14},{
-8,-12,4,-4,8}},{{-8,-16,16,0,24},{-9,-18,18,0,27},{-5,-10,10,0,15},{-7,-14,14,0
,21},{-4,-8,8,0,12}},{{0,-8,24,8,32},{0,-9,27,9,36},{0,-5,15,5,20},{0,-7,21,7,28
},{0,-4,12,4,16}}},{{{-36,-45,-9,-27,0},{-40,-50,-10,-30,0},{-24,-30,-6,-18,0},{
-32,-40,-8,-24,0},{-20,-25,-5,-15,0}},{{-27,-36,0,-18,9},{-30,-40,0,-20,10},{-18
,-24,0,-12,6},{-24,-32,0,-16,8},{-15,-20,0,-10,5}},{{-18,-27,9,-9,18},{-20,-30,1
0,-10,20},{-12,-18,6,-6,12},{-16,-24,8,-8,16},{-10,-15,5,-5,10}},{{-9,-18,18,0,2
7},{-10,-20,20,0,30},{-6,-12,12,0,18},{-8,-16,16,0,24},{-5,-10,10,0,15}},{{0,-9,
27,9,36},{0,-10,30,10,40},{0,-6,18,6,24},{0,-8,24,8,32},{0,-5,15,5,20}}},{{{-40,
-50,-10,-30,0},{-44,-55,-11,-33,0},{-28,-35,-7,-21,0},{-36,-45,-9,-27,0},{-24,-3
0,-6,-18,0}},{{-30,-40,0,-20,10},{-33,-44,0,-22,11},{-21,-28,0,-14,7},{-27,-36,0
,-18,9},{-18,-24,0,-12,6}},{{-20,-30,10,-10,20},{-22,-33,11,-11,22},{-14,-21,7,-
7,14},{-18,-27,9,-9,18},{-12,-18,6,-6,12}},{{-10,-20,20,0,30},{-11,-22,22,0,33},
{-7,-14,14,0,21},{-9,-18,18,0,27},{-6,-12,12,0,18}},{{0,-10,30,10,40},{0,-11,33,
11,44},{0,-7,21,7,28},{0,-9,27,9,36},{0,-6,18,6,24}}}}
***Script terminated.***
It represents quite a lot of hard work with my parser, but now I can finally reap the benefits.
for example: BCScript took less then a day to construct; a few lines of code to initialize the parser, add the BCSH object to the Parser, load the file, basic stuff.
My weak point has always been distribution of my programs, they are so dependent on other components, and I always forget something. I'll see if I can create a Installer for it so anybody interested can try out it's capabilities. While I'm at it I might need to document the extensive feature set.
But it'll take a while for an installer. Last thing I want is to fill people's registries with the CLSID's of my components and have no real way of uninstalling them. So I'll have to do my own bench testing with any installer I create.
Once I figure out how, it will be integrated with CScript and WScript as a ActiveX Scripting Host Engine.
And the := operator is SUPPOSED to be working as an Assignment operator, but I'm having problems with that for some reason. Probably related to me having both a = and a : operator as well.
After finally fixing a few show-stopping bugs in my expression evaluation library, I realized that I could actually use it as the engine for a Custom script language.
In it's first iteration, code such as this:
STORE(X,50);
BCSH@WriteLn("WRITTEN!" + X);
would output:
BASeCamp Commandline BCScript Interpreter.
Copyright 2008-2009 BASeCamp Corporation. All rights reserved.
WRITTEN!50
***Script terminated.***
Which is actually kind of a surprise to me even, since adding the Semicolon as a "statement separator" was a after-thought.
The question will inevitably arise, "what does this language have that VBS or JScript don't?"
quite simple.
intrinsic support for arrays and operations on them. For example, the engine let's you directly specify an array:
STORE(X,{1,2,3,4,5});
BCSH@WriteLn(X);
will store a five element array in X, and then display it. It will be displayed as "{1,2,3,4,5}", which is exactly the same as the way it was input. More amazing, Operations can be performed directly on the array that in other languages would require a loop to perform:
STORE(X,{1,2,3,4,5});
STORE(Y,{5,6,2,4,1});
STORE(Z,(X+Y)*(X-Y));
BCSH@WriteLn("Z=");
BCSH@WriteLn(X);
BCSH@WriteLn(Z);
the output- quite extensive. See, by default, the operations are not scalar on arrays, but rather iterative. For example, {1,2}*{3,4} will be another two elements array, but get this: both items will themselves be arrays, facilitating a matrix: {{1*3,1*4},{2*3,2*4}}
BASeCamp Commandline BCScript Interpreter.
Copyright 2008-2009 BASeCamp Corporation. All rights reserved.
"Z="
{1,2,3,4,5}
{{{{-24,-30,-6,-18,0},{-28,-35,-7,-21,0},{-12,-15,-3,-9,0},{-20,-25,-5,-15,0},{-
8,-10,-2,-6,0}},{{-18,-24,0,-12,6},{-21,-28,0,-14,7},{-9,-12,0,-6,3},{-15,-20,0,
-10,5},{-6,-8,0,-4,2}},{{-12,-18,6,-6,12},{-14,-21,7,-7,14},{-6,-9,3,-3,6},{-10,
-15,5,-5,10},{-4,-6,2,-2,4}},{{-6,-12,12,0,18},{-7,-14,14,0,21},{-3,-6,6,0,9},{-
5,-10,10,0,15},{-2,-4,4,0,6}},{{0,-6,18,6,24},{0,-7,21,7,28},{0,-3,9,3,12},{0,-5
,15,5,20},{0,-2,6,2,8}}},{{{-28,-35,-7,-21,0},{-32,-40,-8,-24,0},{-16,-20,-4,-12
,0},{-24,-30,-6,-18,0},{-12,-15,-3,-9,0}},{{-21,-28,0,-14,7},{-24,-32,0,-16,8},{
-12,-16,0,-8,4},{-18,-24,0,-12,6},{-9,-12,0,-6,3}},{{-14,-21,7,-7,14},{-16,-24,8
,-8,16},{-8,-12,4,-4,8},{-12,-18,6,-6,12},{-6,-9,3,-3,6}},{{-7,-14,14,0,21},{-8,
-16,16,0,24},{-4,-8,8,0,12},{-6,-12,12,0,18},{-3,-6,6,0,9}},{{0,-7,21,7,28},{0,-
8,24,8,32},{0,-4,12,4,16},{0,-6,18,6,24},{0,-3,9,3,12}}},{{{-32,-40,-8,-24,0},{-
36,-45,-9,-27,0},{-20,-25,-5,-15,0},{-28,-35,-7,-21,0},{-16,-20,-4,-12,0}},{{-24
,-32,0,-16,8},{-27,-36,0,-18,9},{-15,-20,0,-10,5},{-21,-28,0,-14,7},{-12,-16,0,-
8,4}},{{-16,-24,8,-8,16},{-18,-27,9,-9,18},{-10,-15,5,-5,10},{-14,-21,7,-7,14},{
-8,-12,4,-4,8}},{{-8,-16,16,0,24},{-9,-18,18,0,27},{-5,-10,10,0,15},{-7,-14,14,0
,21},{-4,-8,8,0,12}},{{0,-8,24,8,32},{0,-9,27,9,36},{0,-5,15,5,20},{0,-7,21,7,28
},{0,-4,12,4,16}}},{{{-36,-45,-9,-27,0},{-40,-50,-10,-30,0},{-24,-30,-6,-18,0},{
-32,-40,-8,-24,0},{-20,-25,-5,-15,0}},{{-27,-36,0,-18,9},{-30,-40,0,-20,10},{-18
,-24,0,-12,6},{-24,-32,0,-16,8},{-15,-20,0,-10,5}},{{-18,-27,9,-9,18},{-20,-30,1
0,-10,20},{-12,-18,6,-6,12},{-16,-24,8,-8,16},{-10,-15,5,-5,10}},{{-9,-18,18,0,2
7},{-10,-20,20,0,30},{-6,-12,12,0,18},{-8,-16,16,0,24},{-5,-10,10,0,15}},{{0,-9,
27,9,36},{0,-10,30,10,40},{0,-6,18,6,24},{0,-8,24,8,32},{0,-5,15,5,20}}},{{{-40,
-50,-10,-30,0},{-44,-55,-11,-33,0},{-28,-35,-7,-21,0},{-36,-45,-9,-27,0},{-24,-3
0,-6,-18,0}},{{-30,-40,0,-20,10},{-33,-44,0,-22,11},{-21,-28,0,-14,7},{-27,-36,0
,-18,9},{-18,-24,0,-12,6}},{{-20,-30,10,-10,20},{-22,-33,11,-11,22},{-14,-21,7,-
7,14},{-18,-27,9,-9,18},{-12,-18,6,-6,12}},{{-10,-20,20,0,30},{-11,-22,22,0,33},
{-7,-14,14,0,21},{-9,-18,18,0,27},{-6,-12,12,0,18}},{{0,-10,30,10,40},{0,-11,33,
11,44},{0,-7,21,7,28},{0,-9,27,9,36},{0,-6,18,6,24}}}}
***Script terminated.***
It represents quite a lot of hard work with my parser, but now I can finally reap the benefits.
for example: BCScript took less then a day to construct; a few lines of code to initialize the parser, add the BCSH object to the Parser, load the file, basic stuff.
My weak point has always been distribution of my programs, they are so dependent on other components, and I always forget something. I'll see if I can create a Installer for it so anybody interested can try out it's capabilities. While I'm at it I might need to document the extensive feature set.
But it'll take a while for an installer. Last thing I want is to fill people's registries with the CLSID's of my components and have no real way of uninstalling them. So I'll have to do my own bench testing with any installer I create.
Once I figure out how, it will be integrated with CScript and WScript as a ActiveX Scripting Host Engine.
And the := operator is SUPPOSED to be working as an Assignment operator, but I'm having problems with that for some reason. Probably related to me having both a = and a : operator as well.