-
Notifications
You must be signed in to change notification settings - Fork 1
Parser
Jump To | Go Back |
Arguments | Methods | Variables |
---|
Implements: Struct
The parser is used to break apart strings based on character runs. By default, it will uses spaces and tabs to break apart strings, but this can be changed by using the divider method.
var _parser = new Parser().parse( "Hello.World!" )
_parser.divider(".");
_parser.next();
Output: "Hello"
Name | Type | Purpose |
---|---|---|
_divider | undef |
No description |
Jump To | top |
parse | clear | restart | has_next | next | remaining | peek | load | save | to_array | size | toString |
---|
Returns: self
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
string | string |
The string to parse |
Sets string as the target for parsing.
Returns: self
Name | Type | Purpose |
---|---|---|
None |
Clears the contents of the parser.
Returns: self;
Name | Type | Purpose |
---|---|---|
None |
Sets the parse position back to the start of the string.
Returns: bool
Name | Type | Purpose |
---|---|---|
None |
Returns true if there is unparsed string remaining.
Returns: string
or EOS
Name | Type | Purpose |
---|---|---|
None |
Returns the next chunk in the string based on the divider. If the end of the string has been reached, EOS is returned instead.
Returns: string
or EOS
Name | Type | Purpose |
---|---|---|
None |
Returns the remaining unparsed string, or EOS if the end of the string has been reached.
Returns: string
or EOS
Name | Type | Purpose |
---|---|---|
None |
Reads and returns the next word in the parser without advancing it. If the end of the param string has been reached, EOS is returned.
Returns: self
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
data | struct |
The saved state to return to. |
Returns the parser to a saved state. If the struct provided is not a valid state, InvalidArgumentType will be thrown.
Returns: struct
Name | Type | Purpose |
---|---|---|
None |
Returns a struct with the state of the parser preserved.
Returns: array
Name | Type | Purpose |
---|---|---|
None |
Breaks up the string into an array and returns it.
Returns: int
Name | Type | Purpose |
---|---|---|
None |
Returns the length of the internal string.
Returns: string
Name | Type | Purpose |
---|---|---|
remaining? | bool |
optional: Whether to only return the remainder |
Returns the string being parsed. If remaining? is true, only the part of the string which has yet to be parsed will be returned.
Jump To | top |
---|
Name | Type | Initial | Purpose |
---|---|---|---|
EOS | struct |
constant | A marker that is returned when the end of the string has been reached. |
__Content | string |
"" | The string being parsed. |
__Divider | string |
" \t" (whitespace) | The character string used to find the next breakpoint. |
__Last | int |
0 | The last position read from. |
Devon Mullane 2020