tamer: xir::tree::ParserState::store_or_emit: Properly emit Parsed::Done
This was forgotten when the attribute parser was introduced, and led to the parser continuing to the token following AttrEnd, which properly caused a failure given that the parser was in the Done state. There is a future task I have in my backlog to properly address the Done state, but this is sufficient for now.main
parent
e0811589fa
commit
d421112f35
|
@ -834,6 +834,10 @@ impl ParserState {
|
|||
Parsed::Attr(attr)
|
||||
}
|
||||
|
||||
// This parser has completed relative to its initial context and
|
||||
// is not expecting any further input.
|
||||
Stack::Done => Parsed::Done,
|
||||
|
||||
_ => {
|
||||
self.stack = new_stack;
|
||||
Parsed::Incomplete
|
||||
|
|
|
@ -480,6 +480,8 @@ fn parser_attr_multiple() {
|
|||
Token::AttrName(attr2, *S2),
|
||||
Token::AttrValue(val2, *S3),
|
||||
Token::AttrEnd,
|
||||
// Token that we should _not_ hit.
|
||||
Token::Text("nohit".into(), *S),
|
||||
]
|
||||
.into_iter();
|
||||
|
||||
|
@ -488,4 +490,12 @@ fn parser_attr_multiple() {
|
|||
assert_eq!(sut.next(), Some(Ok(Attr::new(attr1, val1, (*S, *S2)))));
|
||||
assert_eq!(sut.next(), Some(Ok(Attr::new(attr2, val2, (*S2, *S3)))));
|
||||
assert_eq!(sut.next(), None);
|
||||
|
||||
// Parsing must stop after AttrEnd,
|
||||
// after which some other parser can continue on the same token
|
||||
// stream.
|
||||
// Even if there _were_ more attributes,
|
||||
// this parser is spent and cannot continue.
|
||||
drop(sut);
|
||||
assert_eq!(toks.next(), Some(Token::Text("nohit".into(), *S)));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue