Expand deferred TeX input without recursive dispatch frames
This commit is contained in:
1 parent
ebbc9e2c17
commit
6d54af5350
3 files changed
+66
-19
No files matched your search
@@ -694,36 +694,54 @@ impl Executor {
|
|||||||
return self.fail("native expansion nesting limit exceeded");
|
return self.fail("native expansion nesting limit exceeded");
|
||||||
}
|
}
|
||||||
self.expansion_depth += 1;
|
self.expansion_depth += 1;
|
||||||
let result = if input.frozen {
|
let result = self.expand_with_pending_tokens(input, files, definition_context);
|
||||||
Ok(Some(input))
|
|
||||||
} else {
|
|
||||||
match self.meaning(&input.token) {
|
|
||||||
Meaning::Primitive(Primitive::Expandafter) => {
|
|
||||||
self.expand_after(&input.token, files)
|
|
||||||
}
|
|
||||||
meaning => self.expand_one_inner(input, meaning, files, definition_context),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
self.expansion_depth -= 1;
|
self.expansion_depth -= 1;
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
// Keep the recursive path outside the expansion dispatch frame.
|
|
||||||
fn expand_after(
|
fn expand_with_pending_tokens(
|
||||||
&mut self,
|
&mut self,
|
||||||
token: &Token,
|
mut input: InputToken,
|
||||||
files: &mut impl SourceProvider,
|
files: &mut impl SourceProvider,
|
||||||
|
mut definition_context: bool,
|
||||||
) -> Result<Option<InputToken>, Error> {
|
) -> Result<Option<InputToken>, Error> {
|
||||||
if self.read_parameter(Parameter::Tracingcommands).width() > 1 {
|
let mut pending = Vec::new();
|
||||||
self.trace_command(token, files)?;
|
let mut first = None;
|
||||||
|
let result = loop {
|
||||||
|
if input.frozen {
|
||||||
|
break Some(input);
|
||||||
}
|
}
|
||||||
let first = self.required_raw(files)?;
|
let meaning = self.meaning(&input.token);
|
||||||
let second = self.required_raw(files)?;
|
if !matches!(meaning, Meaning::Primitive(Primitive::Expandafter)) {
|
||||||
if let Some(second) = self.expand_one(second, files, false)? {
|
break self.expand_one_inner(input, meaning, files, definition_context)?;
|
||||||
|
}
|
||||||
|
if self.read_parameter(Parameter::Tracingcommands).width() > 1 {
|
||||||
|
self.trace_command(&input.token, files)?;
|
||||||
|
}
|
||||||
|
// Expanding the second token is the same dispatch with deferred
|
||||||
|
// input. Only a re-entry from a scanner needs a new expansion frame.
|
||||||
|
if let Some(outer) = first.replace(self.required_raw(files)?) {
|
||||||
|
if pending.len() >= self.limits.input_depth {
|
||||||
|
return self.fail("native input stack limit exceeded");
|
||||||
|
}
|
||||||
|
pending.push(outer);
|
||||||
|
}
|
||||||
|
input = self.required_raw(files)?;
|
||||||
|
definition_context = false;
|
||||||
|
};
|
||||||
|
let Some(first) = first else {
|
||||||
|
return Ok(result);
|
||||||
|
};
|
||||||
|
if let Some(second) = result {
|
||||||
self.unread(second)?;
|
self.unread(second)?;
|
||||||
}
|
}
|
||||||
self.unread(first)?;
|
self.unread(first)?;
|
||||||
|
for token in pending.into_iter().rev() {
|
||||||
|
self.unread(token)?;
|
||||||
|
}
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expand_one_inner(
|
fn expand_one_inner(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: InputToken,
|
input: InputToken,
|
||||||
|
|||||||
@@ -150,13 +150,22 @@ fn invalid_quantities_overflows_units_and_readonly_positions_fail() {
|
|||||||
for source in [
|
for source in [
|
||||||
format!("\\number{}0", "\\count".repeat(130)),
|
format!("\\number{}0", "\\count".repeat(130)),
|
||||||
format!("\\number{}0", "\\dimen".repeat(130)),
|
format!("\\number{}0", "\\dimen".repeat(130)),
|
||||||
format!("{}\\relax", "\\expandafter\\relax".repeat(130)),
|
|
||||||
] {
|
] {
|
||||||
let error = Executor::default()
|
let error = Executor::default()
|
||||||
.run(file(&source), &mut FontFiles)
|
.run(file(&source), &mut FontFiles)
|
||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
assert!(error.message.contains("nesting limit"), "{}", error.message);
|
assert!(error.message.contains("nesting limit"), "{}", error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let chain = "\\expandafter A".repeat(64);
|
||||||
|
let source = format!("\\message{{CHAIN:{chain}\\number 17}}");
|
||||||
|
assert_eq!(messages(&run(&source)), [format!("CHAIN:{}17", "A".repeat(64))]);
|
||||||
|
|
||||||
|
let limits = Limits { input_depth: 32, ..Limits::default() };
|
||||||
|
let error = Executor::new(State::default(), limits)
|
||||||
|
.run(file(&source), &mut FontFiles)
|
||||||
|
.unwrap_err();
|
||||||
|
assert!(error.message.contains("input stack limit"), "{}", error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Files(BTreeMap<String, String>);
|
struct Files(BTreeMap<String, String>);
|
||||||
|
|||||||
@@ -1126,6 +1126,26 @@ schema28 更新。schema 1至26和29仍拒绝,27与28缺少必需 Unicode
|
|||||||
[原样模板记录](PUBLISHER_TEMPLATE_MATRIX.md#aps-revtex-原样双栏样稿)
|
[原样模板记录](PUBLISHER_TEMPLATE_MATRIX.md#aps-revtex-原样双栏样稿)
|
||||||
[pdfTeX 的重音布局](https://github.com/TeX-Live/texlive-source/blob/trunk/texk/web2c/pdftexdir/pdftex.web#L28084-L28143)
|
[pdfTeX 的重音布局](https://github.com/TeX-Live/texlive-source/blob/trunk/texk/web2c/pdftexdir/pdftex.web#L28084-L28143)
|
||||||
|
|
||||||
|
### 宏展开调度与实际浮点表达式
|
||||||
|
|
||||||
|
将 `\expandafter` 的暂存 token 留在同一次展开调度。执行第二个 token
|
||||||
|
仍使用原上下文与命令追踪,结果先回退,再按顺序恢复待处理 token。
|
||||||
|
递归重入扫描时仍核对实际展开和扫描深度,输入容量与逐 token 步数
|
||||||
|
保持原接口。64 层直接嵌套的最小样例得到同样的 pdfTeX 输出。
|
||||||
|
|
||||||
|
Elsevier CAS 图形高度和浮点舍入的冻结最小样例已能以原样源码生成
|
||||||
|
一页 PDF。实际图像高72.5539 pt,基线12 pt,浮点结果6.546157836914062,
|
||||||
|
取整7。144 DPI 灰度图逐像素一致。初次仅合并直接连续链的候选仍触发
|
||||||
|
真实浮点样例的展开上限,失败证据保留。最终定向数量和命令追踪共7项
|
||||||
|
通过。置于统一矩阵的原样全项目仍需在同一版本集中验收。
|
||||||
|
|
||||||
|
`target/p3-native-expansion-continuations` 的通过回执:
|
||||||
|
|
||||||
|
- `long-chain-candidate-v2/receipt.json` 为 `2081edb92a50bb26afafd6f5148c945c81a9fbcb6809ce16c660eb0cfdbf91c1`。
|
||||||
|
- `float-candidate-v2/receipt.json` 为 `4686b90bc415229537835459d4da502875b1ee241e6dd079f8045d55b34fd409`。
|
||||||
|
- `float-candidate-v2/render-receipt.json` 为 `6bc7cc5fdecde72879f9890821527959c5a8d23bc72ae638004cef1835bed421`。
|
||||||
|
- `directed-v2.log` 为 `cb3dcaf8a6292a40f43f30d4018f4be4a38033b216ece84153d86fef53004ec6`。
|
||||||
|
|
||||||
### 原生自动字宽伸缩
|
### 原生自动字宽伸缩
|
||||||
|
|
||||||
字宽伸缩参数进入真实字体目录和 schema33 格式。模式1在装盒时按字形
|
字宽伸缩参数进入真实字体目录和 schema33 格式。模式1在装盒时按字形
|
||||||
|
|||||||
Reference in new issue
Block a user