more changes, working on the asm parser
This commit is contained in:
@@ -16,6 +16,33 @@ namespace spider {
|
||||
|
||||
TextReader::~TextReader() {}
|
||||
|
||||
bool TextReader::eat(u32 _char) {
|
||||
if(current() == _char) {
|
||||
nextChar();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TextReader::eat(char _char) {
|
||||
return this->eat(u32(_char));
|
||||
}
|
||||
|
||||
bool TextReader::eat(const std::string& chars) {
|
||||
isize index = 0, count = 0;
|
||||
u32 _char;
|
||||
while(index < chars.length()) {
|
||||
if(!utf8::charAt(chars, index, _char)) return false;
|
||||
if(_char != peekChar(count)) return false;
|
||||
count++;
|
||||
}
|
||||
if(index == chars.length()) {
|
||||
nextChar(count);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
char TextReader::readByte() {
|
||||
if (err) return 0;
|
||||
auto& s = getStream();
|
||||
@@ -49,14 +76,16 @@ namespace spider {
|
||||
/**
|
||||
* Reads the next character and advances the position tracker.
|
||||
*/
|
||||
u32 TextReader::nextChar() {
|
||||
u32 TextReader::nextChar(isize n) {
|
||||
if (err) return 0;
|
||||
|
||||
// Ensure the character we are moving TO exists
|
||||
if (fillBufferTo(1)) {
|
||||
// Track the cursor position using the character we are leaving behind
|
||||
advance(current());
|
||||
bufferIndex++;
|
||||
if (fillBufferTo(n)) {
|
||||
// advance n characters
|
||||
while(n--) {
|
||||
advance(current());
|
||||
bufferIndex++;
|
||||
}
|
||||
return current();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user