simplify lookahead in variable flag parsing

This commit is contained in:
Connor Skees 2021-07-20 11:15:19 -04:00
parent 2969f08e43
commit 2ec365ddfc
3 changed files with 4 additions and 7 deletions

View File

@ -53,11 +53,6 @@ impl Lexer {
self.peek()
}
pub fn truncate_iterator_to_cursor(&mut self) {
self.cursor += self.amt_peeked;
self.amt_peeked = 0;
}
/// Set cursor to position and reset peek
pub fn set_cursor(&mut self, cursor: usize) {
self.cursor = cursor;

View File

@ -132,11 +132,9 @@ impl<'a> Parser<'a> {
match flag.node.as_str() {
"global" => {
self.toks.truncate_iterator_to_cursor();
global = true;
}
"default" => {
self.toks.truncate_iterator_to_cursor();
default = true;
}
_ => {

View File

@ -385,6 +385,10 @@ error!(
no_value_only_flag,
"$a: !default;", "Error: Expected expression."
);
error!(
variable_value_after_flag,
"$a: !default red;", "Error: Expected expression."
);
error!(
uppercase_flag,
"$a: 1 !GLOBAL;", "Error: Invalid flag name."