simplify lookahead in variable flag parsing
This commit is contained in:
parent
2969f08e43
commit
2ec365ddfc
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
_ => {
|
||||
|
@ -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."
|
||||
|
Loading…
x
Reference in New Issue
Block a user