wmww/Pinecone

Add support for Pinecone programs to get command line args

Closed this issue · 11 comments

I've seen a previous commit that allowed command line argument support, but how do I use these arguments in a program?

wmww commented

That commit was for controlling the interpreter with arguments there is currently not support for giving your program arguments. I will update this issue when I implement this.

ok, i will be sure to check by later

I'll try and add this myself soon. If you want.

wmww commented

Go for it. Sorry I haven't added it, I haven't worked on Pinecone much lately.

wmww commented

on lines 193 and 227 in src/main.cpp I set i (the current command line arg being processed) to argc (the cont of the arguments. To implement command line args, make a vector of strings in the Flags struct (in main.cpp), fill that with all the arguments that come after the -e or -r flag and then expose that as a builtin global variable.

wmww commented

On second thought, you might want to make the args vector a global, so you can access it in PineconeStdLib.cpp where you can expose it. If you have any trouble implementing it, let me know.

Currently out, when I get home I'll implement that and then merge.

i haven't used c++ in a while.

But i gave it a go, from what i can remember.

here

It is very much a WIP change.

You're probably better to do it, you know in better detail how you want it to work.

wmww commented

Your patch looks good but still needs some stuff I will add (as per my comment on the PR)

Also, a different system needs to be created for argument parsing when transpiled. For starters, when transpiling and automatically running the arguments after the -e must be carried along to the executed binary. This can be done by using this function on your args vector and appending it to the executed command around here. You can do that on your patch branch if you want. There is other stuff that's needed in the transpiled code, but that's a bit complicated. I'll look into it later.

wmww commented

Merged in your PR with my additions and fixes. It now supports command line args both when compiled or interpreted. Documentation for this feature is at the end of the temporary hacks tutorial.