feat: add basic reset for line

上级 ed1e9e0a
......@@ -165,7 +165,6 @@ impl Grammar {
current_state = state;
} else {
is_first_line = false;
// current_state.as_ref().unwrap().reset();
current_state.reset();
}
......@@ -765,7 +764,7 @@ hellomake: $(OBJ)
#[test]
fn should_resolve_make_file_error_issues2() {
let code = "hellomake: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS)";
\t$(CC) -o $@ $^ $(CFLAGS)";
let grammar = to_grammar_with_code("test-cases/first-mate/fixtures/makefile.json", code);
debug_output(&grammar, String::from("program.json"));
}
......
......@@ -111,5 +111,25 @@ impl StackElement {
return self;
}
pub fn reset(&mut self) {}
pub fn reset(&mut self) {
let mut has_parent = true;
if let None = self.parent {
has_parent = false;
self.enter_pos = -1;
self.anchor_pos = -1;
}
while has_parent {
self.enter_pos = -1;
self.anchor_pos = -1;
if let None = self.parent {
has_parent = false;
} else {
// todo: check parent not null
// self = self.parent.unwrap().borrow_mut();
self.parent = None;
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册