Constructor
new TextParser(data)
Reads elements from strings.
Parameters:
Name | Type | Description |
---|---|---|
data |
string |
- Source:
Members
Methods
atEnd() → {boolean}
- Source:
Returns:
Whether it is at the end of the string.
- Type
- boolean
(private) indexOf_(regexnon-null) → (nullable) {?{position: number, length: number, results: !Array.<string>}}
Returns the index info about a regular expression match.
Parameters:
Name | Type | Description |
---|---|---|
regex |
RegExp |
- Source:
Returns:
- Type
- ?{position: number, length: number, results: !Array.<string>}
readLine() → (nullable) {string}
Reads a line from the parser. This will read but not return the newline.
Returns null at the end.
- Source:
Returns:
- Type
- string
readRegex(regexnon-null) → {Array.<string>}
Reads the given regular expression from the parser. This requires the match
to be at the current position; there is no need to include a head anchor.
This requires that the regex have the global flag to be set so that it can
set lastIndex to start the search at the current position. Returns null at
the end or if the regex does not match the current position.
Parameters:
Name | Type | Description |
---|---|---|
regex |
RegExp |
- Source:
Returns:
- Type
- Array.<string>
(private) readRegexReturnCapture_(regexnon-null, index) → (nullable) {string}
Reads a regex from the parser and returns the given capture.
Parameters:
Name | Type | Description |
---|---|---|
regex |
RegExp | |
index |
number |
- Source:
Returns:
- Type
- string
readWord() → (nullable) {string}
Reads a word from the parser. This will not read or return any whitespace
before or after the word (including newlines). Returns null at the end.
- Source:
Returns:
- Type
- string
skipWhitespace()
Skips any continuous whitespace from the parser. Returns null at the end.
- Source: