Closed nhooyr closed 7 years ago
Do you think I should change the name of the function from parse
to split
and the name of the module to ArgSplitter
?
this parser is way too complex
The complexity is necessary for proper support of quoted arguments. I couldn't find a simpler way to accomplish it.
I feel like the concrete behaviour of this parser is too difficult to reason about for it to be a default. The combination of being able to quote things to get around splitting, and then being able to escape quotes, and then being able to escape escapes. As well as the fact that the implementation for this is really ugly, and also really slow, makes me feel that this isn't a sane default.
It doesn't support escaping escapes (slashes?) as thats not necessary. Only quotes can be escaped.
The implementation may be subjectievly ugly but why do you think it's slow?
In any case, I'll close this PR but we'll have to revert #32 because it was buggy.
This parser does not assume that the first element is unquoted, handles quoted arguments combined with non quoted characters and also supports escaping quotes within a quoted argument.
I also included a small test. In the future, I can break the single test into multiple tests to isolate the functionality tested but I don't think its necessary now.