Surgeon_
Symbian Curator
Good day, people of GMC! Some of you already know what this is. Some of you don't. Either way, it's nothing new, just a continuation of an old thread (Link) about an old asset.
OVERVIEW:
-Name: N String Parser 2
-Version: 2.6.5 (16th of March 2018)
-Purpose: Interpreting GML strings.
-Game Maker version: Studio 1.x*
*-At the time of writing this (16th of March 2018) the asset is also compatible with GMS2.0.
-Target Platform: Any
-Price: Free
-Documentation (.txt): Dropbox link
-View on Marketplace: Link
(NOTE: Due to the forum rules, I'm offering this asset through the Marketplace only; thus the license is now also changed - but it's still as unconstrained as it was before.)
GENERAL DESCRIPTION:
Before Game Maker: Studio, before compiling, when Game Maker was still an interpreted language, there was this function, execute_string(...). Admittedly, it was a source of much controversy, and not without good reasons - it was slow, unsafe, encouraged bad practices and pointed beginner programmers in a wrong direction. However, here's the thing - nowadays, when you run your game to test it, and realize something is not set up properly, you have to exit it, change and recompile it - which could be a very tedious process with larger games. While in the old days, you could simply pop a get_string(...) window and execute what ever you inputted, during runtime, "on the fly". There were some situations where it was simply convenient rather than necessary (parsing math expressions, for example), but, same as all functions, it was a tool at the programmer's disposal and, again, same as all functions, it would cause problems if misused. The goal of this asset is to restore that tool as much as possible, and it's up to programmers to decide in which way they will use it.
DEFINING FEATURES:
-The good:
-Can read and execute GML code.
-Can solve arithmtical and logical equations, and return their outcomes.
-It supports if/else and with statements, and even Repeat and While loops.
-You can set up your own tokens and operators.
-It shouldn't crash your game in case of a syntax error, but only abort execution and report it to you. (However, error checking is not 100% foolproof and in some situations, like when trying to access uninitialized variables, your game will crash anyway.)
-Takes up almost no memory when not in use.
-It's free.
-The neutral:
-I tried to make NSP able to recognise any syntax that would be viable in GML. And while it's not perfect (You still need to put semicolons at the end of every line), it does do a pretty good job at it. On the other hand, all the loops it performs "just to be safe" make it slower than it could have been. But it's intended only for testing / debugging or minimal use when absolutely needed so losing a frame or two (and that's only if you input really long and complicated code) shouldn't matter.
-The bad:
-Does not support arrays / access to dynamic structures with accessors (and this is no longer a planned feature since it really is outside of the scope of this engine).
-NSP's speed, or rather lack thereof. It is glacial and don't say I didn't warn you (though this can be offset somewhat by saving partially parsed strings as stated above).
-Cannot directly access variables and built-in scripts, so this needs to be set up manually at initialization.
-Underlying functions are commented in a way that probably only I can understand. But the ones you should use don't have that problem.
-Here are some examples of what NSP managed to execute / evaluate:
- x=my_number(x+y) / ( (20 mod 14) * ('a'=='a') / (3 - (6+4==7)) ) +16;
- instance_create(x,y,obj_tester).vspeed=2;
- with (other) {instance_destroy()};
- with (instance_create(32,32,obj_tester)) hspeed=1;
- a="my_number(1+my_number( ... +my_number(1))))))))))))))))))))))))))))))";
-Additional:
-DSM: NSP has a quick access functionality for a single global ds_map (use nspDsMsp to reference it if you need to). In the nsp_initialize script you'll need to enable DSM and set a reference word for it (by default it's "NSP_DSM"). Later, when executing code using NSP you can write NSP_DSM.a=5, (or instead NSP_DSM whatever name you defined), and it will assign 5 to the key "a" in that ds_map. Later, when you need to retreive that value, just use NSP_DSM.a again. You can also use NSP_DS+=a, NSP_DSM*=a etc. DSM is useful because ds_map keys can be strings and so can be accessed dynamically (in other words, when using DSM you can use any variable name, not just those defined in nsp_variable_*functions)
-Saving: Before doing anything, NSP converts the input string into two lists, which is a more organized and accessible format for it. It turns out that this takes much more time than what comes afterwards, and that if you cave those lists you can execute the same string many times with less strain on the CPU.
=== CHANGELOG: ===
=== ===
IMPORTANT NOTE:
Some scripts in this parser are user-editable (namely the script execution one and NSP_variable_* ones) to enable additional functionality - calling Game Maker's built-in functions or using instance variables in expressions. Just remember to save your edited version prior to updating to a new version so that you can restore your modifications later. I don't think any of these scripts will be changed in future updates, but if it happens, I'll make sure to point it out.
Regards, Surgeon_
OVERVIEW:
-Name: N String Parser 2
-Version: 2.6.5 (16th of March 2018)
-Purpose: Interpreting GML strings.
-Game Maker version: Studio 1.x*
*-At the time of writing this (16th of March 2018) the asset is also compatible with GMS2.0.
-Target Platform: Any
-Price: Free
-Documentation (.txt): Dropbox link
-View on Marketplace: Link
(NOTE: Due to the forum rules, I'm offering this asset through the Marketplace only; thus the license is now also changed - but it's still as unconstrained as it was before.)
GENERAL DESCRIPTION:
Before Game Maker: Studio, before compiling, when Game Maker was still an interpreted language, there was this function, execute_string(...). Admittedly, it was a source of much controversy, and not without good reasons - it was slow, unsafe, encouraged bad practices and pointed beginner programmers in a wrong direction. However, here's the thing - nowadays, when you run your game to test it, and realize something is not set up properly, you have to exit it, change and recompile it - which could be a very tedious process with larger games. While in the old days, you could simply pop a get_string(...) window and execute what ever you inputted, during runtime, "on the fly". There were some situations where it was simply convenient rather than necessary (parsing math expressions, for example), but, same as all functions, it was a tool at the programmer's disposal and, again, same as all functions, it would cause problems if misused. The goal of this asset is to restore that tool as much as possible, and it's up to programmers to decide in which way they will use it.
DEFINING FEATURES:
-The good:
-Can read and execute GML code.
-Can solve arithmtical and logical equations, and return their outcomes.
-It supports if/else and with statements, and even Repeat and While loops.
-You can set up your own tokens and operators.
-It shouldn't crash your game in case of a syntax error, but only abort execution and report it to you. (However, error checking is not 100% foolproof and in some situations, like when trying to access uninitialized variables, your game will crash anyway.)
-Takes up almost no memory when not in use.
-It's free.
-The neutral:
-I tried to make NSP able to recognise any syntax that would be viable in GML. And while it's not perfect (You still need to put semicolons at the end of every line), it does do a pretty good job at it. On the other hand, all the loops it performs "just to be safe" make it slower than it could have been. But it's intended only for testing / debugging or minimal use when absolutely needed so losing a frame or two (and that's only if you input really long and complicated code) shouldn't matter.
-The bad:
-Does not support arrays / access to dynamic structures with accessors (and this is no longer a planned feature since it really is outside of the scope of this engine).
-NSP's speed, or rather lack thereof. It is glacial and don't say I didn't warn you (though this can be offset somewhat by saving partially parsed strings as stated above).
-Cannot directly access variables and built-in scripts, so this needs to be set up manually at initialization.
-Underlying functions are commented in a way that probably only I can understand. But the ones you should use don't have that problem.
-Here are some examples of what NSP managed to execute / evaluate:
- x=my_number(x+y) / ( (20 mod 14) * ('a'=='a') / (3 - (6+4==7)) ) +16;
- instance_create(x,y,obj_tester).vspeed=2;
- with (other) {instance_destroy()};
- with (instance_create(32,32,obj_tester)) hspeed=1;
- a="my_number(1+my_number( ... +my_number(1))))))))))))))))))))))))))))))";
-Additional:
-DSM: NSP has a quick access functionality for a single global ds_map (use nspDsMsp to reference it if you need to). In the nsp_initialize script you'll need to enable DSM and set a reference word for it (by default it's "NSP_DSM"). Later, when executing code using NSP you can write NSP_DSM.a=5, (or instead NSP_DSM whatever name you defined), and it will assign 5 to the key "a" in that ds_map. Later, when you need to retreive that value, just use NSP_DSM.a again. You can also use NSP_DS+=a, NSP_DSM*=a etc. DSM is useful because ds_map keys can be strings and so can be accessed dynamically (in other words, when using DSM you can use any variable name, not just those defined in nsp_variable_*functions)
-Saving: Before doing anything, NSP converts the input string into two lists, which is a more organized and accessible format for it. It turns out that this takes much more time than what comes afterwards, and that if you cave those lists you can execute the same string many times with less strain on the CPU.
=== CHANGELOG: ===
(16/03/2018) v2.6.5 Released:
-No changes to NSP functionality-wise, but it's now compatible with GMS2.0.
(11/03/2018) v2.6.2 Released:
-Fixed a bug which caused memory leaks if you passed an empty string to execute.
(18/02/2018) v2.6.1 Released:
-Fixed a bug where identifiers containing "mod" or "div: would be interpreted as operands.
(21/10/2017) v2.5.7 Released:
-Fixed a bug which caused the parser to remove pluses if they were standing directly after a closed parenthesis.
(08/09/2017) - v2.5.6 Released:
-Fixed errors that occurred when an operator was at the beginning of the string.
-Added support for unary + and -
-The parser can now utilize variable_instance_* and variable_global_* functions to access any variables dynamically and in a safer manner.
-Added more competent string recognition through a new tidy-and-verify phase which means that you'll get fatal errors less often now.
-Added a new function: NSP_check_saved(...) - more info in the documentation.
(27/08/2016) - v2.5.1 Released:
-Added support for "else" statements to complement the use of "if" statements.
(17/08/2016) - v2.5.0 Released:
-Added support for "return" statements, so the string-executing functions can now also return a value.
-Fixed a small bug which would in some cases show an error for no reason.
(23/06/2016) - v2.4.9 Released:
-Fixed a bug which caused DSM to not be freed when freeing the rest of the parser.
(27/02/2016) - v2.4.5 Released:
-Some useful bug fixes.
-Better bug reports where it was possible.
(26/01/2016) - v2.4 Released:
-Fixes some serious issues with control structures (if, while etc.) which would crash your game in most cases.
-As of now, NSP 2 is considered a "stable" version.
(25/01/2016) - v2.3 Released:
-Fixed a bug with variable scoping which prevented long strings / code from executing properly.
-Fixed a bug with executing strings, where NSP would pass malformed arguments if they were strings.
-Fixed a bug with assigning values to global variables, where the assigned value would be malformed if it was a string.
(21/11/2015) - v2.2 Released:
-Fixed issues with DSM; It should work properly now.
-Added support for constants via nsp_get_constant(...). Read the Documentation for more info.
-Better syntax error checking.
-Updated documentation.
(20/11/2015) - v2.1 Released:
-Fixed a major bug which prevented ifs and loops from working properly.
-Fixed some other, smaller bugs in the code.
-NSP_free(...) can now also clear any data stored by using NSP_save(...) function so you don't have to do it manually.
-Removed all usage of "globalvar".
(07/11/2015) - v2.0 Released:
-Initial release.
-No changes to NSP functionality-wise, but it's now compatible with GMS2.0.
(11/03/2018) v2.6.2 Released:
-Fixed a bug which caused memory leaks if you passed an empty string to execute.
(18/02/2018) v2.6.1 Released:
-Fixed a bug where identifiers containing "mod" or "div: would be interpreted as operands.
(21/10/2017) v2.5.7 Released:
-Fixed a bug which caused the parser to remove pluses if they were standing directly after a closed parenthesis.
(08/09/2017) - v2.5.6 Released:
-Fixed errors that occurred when an operator was at the beginning of the string.
-Added support for unary + and -
-The parser can now utilize variable_instance_* and variable_global_* functions to access any variables dynamically and in a safer manner.
-Added more competent string recognition through a new tidy-and-verify phase which means that you'll get fatal errors less often now.
-Added a new function: NSP_check_saved(...) - more info in the documentation.
(27/08/2016) - v2.5.1 Released:
-Added support for "else" statements to complement the use of "if" statements.
(17/08/2016) - v2.5.0 Released:
-Added support for "return" statements, so the string-executing functions can now also return a value.
-Fixed a small bug which would in some cases show an error for no reason.
(23/06/2016) - v2.4.9 Released:
-Fixed a bug which caused DSM to not be freed when freeing the rest of the parser.
(27/02/2016) - v2.4.5 Released:
-Some useful bug fixes.
-Better bug reports where it was possible.
(26/01/2016) - v2.4 Released:
-Fixes some serious issues with control structures (if, while etc.) which would crash your game in most cases.
-As of now, NSP 2 is considered a "stable" version.
(25/01/2016) - v2.3 Released:
-Fixed a bug with variable scoping which prevented long strings / code from executing properly.
-Fixed a bug with executing strings, where NSP would pass malformed arguments if they were strings.
-Fixed a bug with assigning values to global variables, where the assigned value would be malformed if it was a string.
(21/11/2015) - v2.2 Released:
-Fixed issues with DSM; It should work properly now.
-Added support for constants via nsp_get_constant(...). Read the Documentation for more info.
-Better syntax error checking.
-Updated documentation.
(20/11/2015) - v2.1 Released:
-Fixed a major bug which prevented ifs and loops from working properly.
-Fixed some other, smaller bugs in the code.
-NSP_free(...) can now also clear any data stored by using NSP_save(...) function so you don't have to do it manually.
-Removed all usage of "globalvar".
(07/11/2015) - v2.0 Released:
-Initial release.
IMPORTANT NOTE:
Some scripts in this parser are user-editable (namely the script execution one and NSP_variable_* ones) to enable additional functionality - calling Game Maker's built-in functions or using instance variables in expressions. Just remember to save your edited version prior to updating to a new version so that you can restore your modifications later. I don't think any of these scripts will be changed in future updates, but if it happens, I'll make sure to point it out.
Regards, Surgeon_
Last edited: