Store single native input tokens inline

This commit is contained in:
gloamxun committed 2026-11-29 05:39:18 +08:00
1 parent 9c93ff9750
commit fb5cb5ada9
6 files changed
+64 -16

No files matched your search

@@ -128,7 +128,7 @@ impl Executor {
let mut t: InputToken =
Token::new(TokenKind::Command(CommandName::FrozenRelax), self.current).into();
t.alignment = Some(boundary);
self.push(vec![t])
self.push_token(t)
}
// Called by raw before a token can be consumed by any expandable scanner.
pub(super) fn alignment_raw(&mut self, token: &InputToken) -> Result<bool, Error> {
@@ -38,7 +38,6 @@ impl Executor {
let Some(input) = self.inputs.last_mut() else {
return Ok(None);
};
let mut warnings = Vec::new();
let next = match input {
InputFrame::Tokens { tokens, cursor, .. } => {
let t = tokens.get(*cursor).cloned();
@@ -88,8 +87,8 @@ impl Executor {
..
} => {
let token = mouth.next(&self.state, &mut self.reads);
warnings = mouth.take_utf8_warnings();
match token {
let warnings = mouth.take_utf8_warnings();
let next = match token {
Ok(Some(token)) => {
self.input_position = Some((*source, mouth.line_number()));
Next::Token(Some(token.into()))
@@ -123,7 +122,11 @@ impl Executor {
}
}
Err((span, text)) => Next::Error(span, text),
};
if !warnings.is_empty() {
self.observe_xe_utf8_warnings(warnings, files)?;
}
next
}
InputFrame::Hook { tokens, cursor, .. } => {
let t = tokens.get(*cursor).cloned().map(InputToken::from);
@@ -134,7 +137,6 @@ impl Executor {
}
InputFrame::Boundary => Next::Boundary,
};
self.observe_xe_utf8_warnings(warnings, files)?;
match next {
Next::Token(Some(token)) => {
self.current = token.token.invocation.unwrap_or(token.token.span);
@@ -117,7 +117,7 @@ impl Executor {
});
character.xe_backed_char = true;
self.discard_exhausted_tokens();
self.push_kind(vec![character], TokenInputKind::BackedUp)?;
self.push_input_tokens(InputTokens::One(character), TokenInputKind::BackedUp)?;
self.push_xe_inter_char_tokens(tokens)?;
return Ok(true);
}
@@ -241,7 +241,7 @@ impl Executor {
display: self.display.take(),
});
self.inputs.push(InputFrame::Tokens {
tokens: tokens.iter().cloned().map(InputToken::from).collect(),
tokens: InputTokens::Many(tokens.iter().cloned().map(InputToken::from).collect()),
cursor: 0,
kind: TokenInputKind::Output,
});