Inspect original primitives and unexpanded tokens

This commit is contained in:
gloamxun committed 2026-11-28 14:01:12 +08:00
1 parent c094d9a81d
commit 2007ac5627
7 files changed
+147 -11

No files matched your search

+14 -3
View File
@@ -1154,7 +1154,8 @@ impl Executor {
}
Iftrue | Iffalse | Ifx | Ifnum | Ifdefined | If | Ifcat | Ifodd | Ifcsname
| Ifcase | Ifeof | Ifdim | Ifpdfabsnum | Ifpdfabsdim | Ifvmode | Ifhmode
| Ifmmode | Ifinner | Ifvoid | Ifhbox | Ifvbox | Iffontchar | Ifincsname => {
| Ifmmode | Ifinner | Ifvoid | Ifhbox | Ifvbox | Iffontchar | Ifincsname
| Ifprimitive | Ifpdfprimitive => {
self.evaluate_conditional(primitive, token.span, false, files)?;
}
Unless => {
@@ -1519,6 +1520,16 @@ impl Executor {
let next = self.normal_raw(files)?.token;
self.meaning(&next) != Meaning::Undefined
}
Ifprimitive | Ifpdfprimitive => {
let operand = self.normal_raw(files)?;
let live = self.meaning(&operand.token);
matches!(
&operand.token.kind,
TokenKind::Command(name)
if !Self::suppresses_meaning(&operand, &live)
&& self.state.original_primitive(name) == Some(&live)
)
}
Ifcsname => {
let name = self.csname(files)?;
self.record_meaning_read(&name);
@@ -4033,8 +4044,8 @@ impl Executor {
Aftergroup => self.schedule_after_group(files)?,
Showbox => self.show_box(files)?,
Showlists | Showgroups | Showifs => self.show_activity(primitive, files)?,
Show | Showthe => self.show(
primitive == Showthe,
Show | Showthe | Showtokens => self.show(
primitive,
token.invocation.unwrap_or(token.span),
files,
)?,