Constructor
new CharacterStream(pattern)
Create a new streamer object
Name | Type | Description |
---|---|---|
pattern | string | the pattern string to iterate over |
Members
buffer
Buffered characters from the stream
col_utf16
Current column number in UTF-16 encoding
col_utf32
Current column number, in UTF-32 encoding
line
Current line number, where lines are given by '\n' character
pattern
Pattern we're iterating over for this stream
stream
Character stream generator
Methods
buffer(nopt) → {boolean}
Ensure at least n>0 characters are buffered if possible
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
n | number | <optional> | 1 | number of characters to buffer |
true if we could fulfill buffer request
- Type:
- boolean
discard(nopt) → {boolean}
Discard n>0 characters; throws if there are not n characters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
n | number | <optional> | 1 | number of characters to discard |
true if we could fulfill discard request
- Type:
- boolean
error(expected, discardopt)
Throw a syntax error at this point in the stream
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
expected | string | message indicating what was expected; prefix/suffix is generated | ||
discard | number | <optional> | 0 | how many buffered characters were okay; the next character (possibly buffered) after those discarded is the one that triggered the error |
peek(nopt) → (nullable) {string}
Fetch n>0 characters as a string
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
n | number | <optional> | 1 | number of characters to peek |
the peeked string; null if we can't get n characters
- Type:
- string
pop(nopt) → (nullable) {string}
Fetch n>0 characters and discard them
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
n | number | <optional> | 1 | number of characters to pop |
the popped string; null if we can't get n characters
- Type:
- string