Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a string with commas as a macro argument confuses the parser #23

Closed
jtackaberry opened this issue Jul 1, 2016 · 8 comments
Closed
Labels

Comments

@jtackaberry
Copy link

If you have a macro that accepts an argument that's used as a string and then pass a string containing a comma, the parser confuses the commas as separate arguments and complains about incorrect number of arguments.

Test case:

macro test(msg)
    message(msg)
end macro

test("this, breaks, the, parser")

Functions don't have this problem, and in fact can mask the macro issue through indirection:

macro _test(msg)
    message(msg)
end macro

function test(msg)
    _test(msg)
end function

test("this, works, fine")
@eitherys
Copy link
Collaborator

eitherys commented Jul 1, 2016

Yes, we've had this problem in the past in our projects. I confirm this issue.

@andreasOL16
Copy link

Hmmm...works for me without problems...

@SamWindell
Copy link
Contributor

It seems to work okay for me at the moment, but I believe you that this is sometimes an issue. At the beginning of the compiling process all strings in the script stored and each string is replaced with a number so that they can be put back in further down the process.

I'm not sure on the exact circumstances, but I think these string placeholders are sometimes not made. This could be why the comma in strings work correct only sometimes. I will have look about fixing this.

@eitherys
Copy link
Collaborator

eitherys commented Jul 1, 2016

I don't know if it helps, but for us it always happened because we used a macro that did a control declaration and help text in one go. Whenever we put commas in the string for the help text argument, it would break:

macro ui.slider(#name#, #min#, #max#, #help#, #default#)
    blah blah blah
end macro
ui.slider(VOLUME, 0, 1000000, "This slider is so cool, it doesn't even need a callback!", 500000)

Granted we've now adopted the better control methods in the updated SublimeKSP (the "control -> par := value" functionality is AWESOME!), so we don't deal with it anymore.

@jtackaberry
Copy link
Author

the "control -> par := value" functionality is AWESOME!

Oh, awesome indeed! I didn't even know about this. I looked again at the documentation and couldn't find it mentioned anywhere. There's one snippet of code in the section about multidimensional UI arrays that quietly uses this syntax and I missed it.

Maybe I'm blind. :)

@SamWindell
Copy link
Contributor

the "control -> par := value" functionality is AWESOME!

It is great! This is from Nils' features, but I don't believe it is documented anywhere. I'll quickly add it to the wiki.

@andreasOL16
Copy link

You find it documented in

http://nilsliberg.se/ksp/history.txt

Search for "Added new control parameter access feature (see example 3)"

@eitherys eitherys added the Bug label Sep 24, 2017
@eitherys
Copy link
Collaborator

eitherys commented Jun 8, 2019

Fixed in the latest feature merge

@eitherys eitherys closed this as completed Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants