StringParser
String parser, tokenizing the input as requested by the function calls. Intended for command argument parsing, but can be used for other things too if needed.
This parser supports:
Keyword arguments at any position (key=value)
Flag arguments at any position (--key value)
Quoted arguments with spaces ("value value value")
Unquoted arguments without spaces (value)
The recommended workflow is as follows:
Call parseNamed to parse out the keyword/flag arguments, removing them from the cursor
Call parseNext as required to parse out single or quoted tokens sequentially
Use the other functions to parse in more specific ways
Parameters
Input string to parse.
Functions
Consume whatever is left in the cursor, setting it to the end of its input string.
Parse all of the flag and keyword arguments out of the cursor, creating a new Cursor containing only the positional arguments and returning a list of parsed NamedArgumentTokens.
Attempt to parse a single or quoted positional argument token from the cursor, returning it if there was a token, or null if there wasn't anything left to parse.
Attempt to parse the next token and reset the cursor's index to what it was before parsing, before returning the result.
Return whatever remains in the cursor's string, without consuming it'.
Collect characters from the cursor while the predicate returns true, and return those characters joined into a String. If the predicate fails on the first character, null will be returned instead. After characters have been collected, the cursor's index is reset, so the characters won't be consumed.