#any open source, GML parsers or string_execute?
1 messages · Page 1 of 1 (latest)
Yeah that's kinda the issue. The closer it can possibly resemble GML the better.
there were some attempts a while ago for pre-2.3 GML but post 2.3 i think people gave up trying
left it to Vadym
Yeah I seen mimpy's string execute. And obviously GMLive. How ever the first is broken, and the second one close source
if it's a personal project i'm sure Vadym wouldn't mind you doing a little hacking
i think GMLive even has a string_execute-ish feature doesn't it?
Does it?
But yeah just making a portable GM notebook. For use on long trips where you can't bring your laptop. Neeri was looking for something for Android and I've wanted something similar for a while. So figured it was about time to try some attempt at it. Doesn't even need to support most of GM, it's just code snippets for testing.
super cool!
good luck!
i have no idea where to start with that stuff. compilers are scary man
haha
Yeah after speaking with Knno, creator of kengine, TXR seems extremely viable if proper GML syntax is desired.
@summer kraken I have a question in relation to TXR, and I was wondering if a function defined in the executed string is possible to define. I assume it would act internally like a macro and parentheses tokens do. So TXR would just execute the tokens until a break/return/exit is met.
you'd want a function literal to become a node that emits a method that does txr_exec of its contents or something
Ah so I'd need to snip that bit out, then txr_exec, and handle its return if any?
I think treating it as a separate program is the easiest
IIRC TXR's "programs" are just arrays with nothing that has to be manually destroyed, yeah?
As a note. This is the example input text.
@'
function log(str) {
return show_debug_message(str)
}
log("hello world")
'
GML itself handles function name() as name = function()
Depending, it could be global.name but yeah that's what I've picked up
cool trick time, try doing show_debug_message(self) outside of a script
(it's global)
Though the function it's self is still a, 'at compile time' reference. Which is what I was planning to try for txr
Oh yes good point
Ah yeah.. speaking of
https://github.com/YAL-GameMaker/tiny-expression-runtime/issues/1
mhm
Alright, I think I have a good grasp on it now. Excited to try it out when I get home.
That's how I'd do it.. I'll have to read writing interprets again
Thanks for the suggestion yal..
Btw, I would also want to make array syntax.. but also not sure how to start
No just simply a index like this
myarray[0]
I think that's supported in git version
Yeah I thought I seen that too
Oh okay, I'll try it
git version has a bunch more stuff than the post did because people would ask me for something small and I'd add that
Tomorrow I'll try to see if I can do something for functions
And maybe a git pr
Ok but theoretically can we have constructors in a txr program?
I might try to write that too.. but a suggestion or guidance would be great
constructors are kind of tricky since you can't bind metadata to a constructor function
if it's only used inside the TXR program though, you can represent it in whatever way you want
Yea just inside the txr program I believe
For my purposes yes. But imagine others would need a better solution.
How ever I would be interested in a GM feature request to include such data into the static struct for new runtime.
I could tell you the idea that I have considered for GMLive, but you will cry
Check for txr meta data, if none exists check for GML metadata?
function __constructor_0() {
// (collect arguments into an array)
txr_construct(0, arg_array);
}
repeat 500 times and maintain a pool of "vacant" constructors to hand to the game code
wondering why you want to reinvent the wheel?
if you're just gonna try write your own compiler, just use Catspeak
you can generate your own code using the IR interface, or even write your own parser for it
Catspeak isn't limited to just "the Catspeak language"
it's more of a compiler framework like LLVM, which you can compile to an IR, and then that IR can get further compiled into callable GML functions and (in the future) interpreted VM
lots of people recently have been asking about execute_string, and every time someone brings up Catspeak it's always discarded as not being GML enough
rly demotivates me
Sorry that wasn't really the intent. I think the main reason why i sidestepped Katspeak was probably because current open source implementations to not appear similar enough to gml, so when i would go about implementing it, a lot of what i'd be doing is reading through docs and probably end up with something a bit more hacky, as i've not used katspeak before, and would be doing something a bit different.
If you're available some time maybe we could speak about the implementation of this further in DMs? I've been looking into TXR, but it also has its issues trying to near-perfectly imitate gml. So it would be refreshing to get your take on using Katspeak.
Catspeak mirrors GML semantically, it's only syntactically different because that's how i wanted it to be
the reason i mention it is because Catspeak already supports function definitions, like
let log = fun(str) {
return show_debug_message(str)
}
log("hello world")
you can use #katsaii___catspeak for questions, and if it's just the syntax you want to be different i can walk you through creating your own parser
really appreciate it. Yeah i'll be available the week after next to look further into this.
From my side
I don't know but it's feature-rich for me, as I am writing my own big engine and I don't really know how catspeak works internally. Also performance wise I dont know I feel like txr is more lightweight that's all. So yea, personally I do need external scripts but it's that I feel for my engine it's overkill. Since my engine should just ask for simple scripts like an init script that sets some vars that's all.
like booleans to set behaviors enabled or not etc.
Is there a comparison regarding performance?
probably similar speed, Catspeak is heavily under optimised but still manages to get close to GML performance
i imagine TXR may have similar gains, though I'm not sure, i trust YAL knows what he's doing
btw the interface for Catspeak is very simple and similar to TXR
TXR:
txr_function_add("show_message", show_message, 1);
var pg = txr_compile(@'
var hi = "hello from TXR";
show_message(hi);
');
txr_exec(pg);
Catspeak:
Catspeak.interface.exposeFunction("show_message", show_message);
var func = Catspeak.compileGML(Catspeak.parseString(@'
let hi = "hello from Catspeak";
show_message(hi);
'));
func();
it necessarily needs to do some things different, but if all you want is basic scripts it's really similar
I'm not sure, I trust YAL knows what he's doing
This is a bold claim, I am un familiar with both systems, but with confidence such as that... I mean obviously one can't look away easily. I suppose it's time for a couple tests next time I'm free.
Personally the importance of it is due to the compile times, and with little experience in both, I must say my interests has peaked in both a lot from a statement as such.
(Please note im only curious and am not encouraging aggressions., but ya know... if it make libraries better i mean... :P)
Sorry if i pinged you Katsaii, i may have
compile times are not a big deal, you should really only be compiling a script once
runtime is more important, and that's what i was referring to
last i checked i can run this code:
let n = 1000
while n {
n -= 1
}```
in Catspeak around 80 times per frame without dropping frames
so 80000 iterations aint too bad