!! UPDATE (7.18) !!
Sourceforge has been updated. Board pastes will be updated later. Tired now. Passing functions with parameters is buggy, without parameters should work properly. This is the last known bug.
Download:
https://sourceforge.net/projects/infinitemonkeys616/files/json_basic.zip/download
#ADDED#
Variables of JSON type
Basic Math Operators and Functions
Basic String Operators and Functions
Assignment Operators
Comparison operators ( ==, <=, >=, <, >, !=, <> )
Conditional statements (if,else)
Array/String Operator Pluck myArray[ index ]
for loop
while loop
myArray[ index ] = value
objects
object[ key ]
object.key
object[ key ] = someValue
object.key = someValue
array.push_back( someValue )
array.pop( index )
array.push( index, someValue )
array.left( index )
array.right( index )
array.mid( index, length )
array.slice( index1, index2 )
array.first
array.last
array.length
len(array) still works
string.split( delimiters, array )
split( string, delimiters, array )
string.slice( index1, index2 )
slice( string, index1, index2 )
string.length
select & case
bitwise && and || or if you please and and or
typeof( variable )
Scoping implemented for functions, if, for, and while
array.clear
#NEW#
Dynamic Scoping:
Keep in mind: Firstly, any variable declared in the implicit main scope is considered shared. It is part of variables.vars[0] (from the context) which can never be popped from the vector. Secondly, all bracketed expressions now create their own scope. You must close them off with an end line. Bracketed expressions are treated like a single line and run the through parser together. Scope is popped immediately after the bracket is closed, and that information is lost. Non-variable expressions are printed as strings. So when the scope containing 'y' is popped it simply prints 'y'.
Code: Select all
var x = 10;
{
print( x );
var y = 20;
print( y );
};
print( x );
print( y );
Self-Parsing Functions
Code: Select all
var s = load_file_as_string( "Examples/array.jsb" );
parse( s );
There is hardly anything to bear in mind about this. It simply calls the same function JSB uses to parse any script. You can also call the Evaluator which is for single lines or sub-lines. So for instance you can dereference a variable using eval. Much testing must be done. But something like this works:
Code: Select all
var s = "beep;";
eval( s );
Var Len Arg Functions
So, if you're interested in adding your own functions to JSB, you really do not have to specify a signature anymore. You can follow the instructions further down this thread to add your own function. As a standard, I use "%f(%a,...)" as a signature. JSB can count how many parameters there are in a function pass and build the arguments and pass them automatically.
Now I need a break. There may be some glitches. If you run into anything, lemme know. Thx.
#TO ADD#
grammar
test suite
Lots of other stuff
^WORTH NOTING^
#1. I have a lot of tests to run.
#2. I have a lot of debugging to do
#3. I have some optimizing to do
#4. I don't know what I'm doing
#5. The parser is mostly recursive calls to itself
#6. The parser is a lot of macros
#7. The code is mostly unreadable ( sorry )