Emscripten: More robust -s parsing

Created on 12 Jan 2018  路  8Comments  路  Source: emscripten-core/emscripten

As suggested by @floooh on the mailing list, we could do this in a better way, that doesn't depend so much on quoting details. The only cases we have are

  • -s X=Y for Y being a number
  • -s X="Y" for Y being a string
  • -s X=["Y1", "Y2", [..]] for Y1 etc being strings

So we could just write our own little parser, that could for example accept -s X=name or -s X=[name1, name2, name3] even without quotes, since there is no risk of ambiguity.

good first bug help wanted wontfix

Most helpful comment

I would also love to make the space after the -s optional. e.g. -sFOO=10. That way each option can be atomic.

Also for arrays maybe we could also make the [] optional. e.g. -sEXPORT=foo,bar,baz.

All 8 comments

I can take this one.

That would be great, thanks @ZhenjieRuan !

One more thing to consider here is that in the discussion in #6057 we are considering adding a settings file option. In that case, we'd want it to support the same flexible notation for -s options as in this issue. So if we make -s more flexible here, we'd need to allow that flexibility in the settings file too. So maybe more thinking is needed here before implementation.

I would also love to make the space after the -s optional. e.g. -sFOO=10. That way each option can be atomic.

Also for arrays maybe we could also make the [] optional. e.g. -sEXPORT=foo,bar,baz.

@ZhenjieRuan are you still interested in doing this? I was hoping we'd make progress in #6057 first as I said earlier, but sadly it looks like no one is working on that. I don't think we should block on that any more, we can do this one first.

@sbc100 both of those are good ideas I think, nice.

Are there any cases in which an option takes a number but needs it as a string? If not quotes could be optional for anything other than preserving spaces.

@curiousdannii I think that's correct, our numbers don't need quoting (we don't mix types in settings), so quotes could be optional for numbers, that would be nice.

Reopening, as that PR improved things a lot but we had some more ideas here for how to improve -s parsing.

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nerddan picture nerddan  路  4Comments

lormuc picture lormuc  路  4Comments

yahsaves picture yahsaves  路  4Comments

answer1103 picture answer1103  路  4Comments

void4 picture void4  路  3Comments