Execute XeTeX Unicode delimiter codes and primitives
This commit is contained in:
1 parent
dba73f1f47
commit
01b3931ae0
13 files changed
+285
-45
No files matched your search
@@ -11,6 +11,54 @@ impl Executor {
|
||||
self.new_noad(NoadClass::Ord, MathField::Box(Box::new(b)), self.current);
|
||||
Ok(())
|
||||
}
|
||||
pub(super) fn scan_delimiter_code_index(
|
||||
&mut self,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<u32, Error> {
|
||||
let maximum = if self.state.input_profile() == InputProfile::XeTeX {
|
||||
0x10_ffff
|
||||
} else {
|
||||
255
|
||||
};
|
||||
self.character_number("delcode index", maximum, files)
|
||||
}
|
||||
|
||||
pub(super) fn read_delimiter_code(&mut self, c: u32) -> i32 {
|
||||
self.reads.insert(match u8::try_from(c) {
|
||||
Ok(slot) => Dependency::DelCode(slot),
|
||||
Err(_) => Dependency::UnicodeDelCode(c),
|
||||
});
|
||||
self.state.delimiter_code(c)
|
||||
}
|
||||
|
||||
fn scan_extended_delimiter_code(&mut self, files: &mut impl SourceProvider) -> Result<i32, Error> {
|
||||
let family = self.scan_math_family(files)?;
|
||||
let slot = self.scan_delimiter_code_index(files)?;
|
||||
Ok(math::Delimiter::EXTENDED | (i32::from(family) << 21) | slot as i32)
|
||||
}
|
||||
|
||||
pub(super) fn scan_delimiter_code_assignment(
|
||||
&mut self,
|
||||
primitive: Primitive,
|
||||
global: bool,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
let slot = self.scan_delimiter_code_index(files)?;
|
||||
self.optional_equals(files)?;
|
||||
let word = if primitive == Primitive::Udelcode {
|
||||
self.scan_extended_delimiter_code(files)?
|
||||
} else {
|
||||
self.integer(files)?
|
||||
};
|
||||
if primitive == Primitive::Delcode && word >= 1 << 24 {
|
||||
return self.fail("delcode must be at most 16777215");
|
||||
}
|
||||
let equivalent = self.state.delimiter_code(slot) == word;
|
||||
self.assign_equivalence(Key::Delcode(slot), global, equivalent, files, |state| {
|
||||
state.assign_delcode(slot, word, global);
|
||||
})
|
||||
}
|
||||
|
||||
fn scan_delimiter(
|
||||
&mut self,
|
||||
files: &mut impl SourceProvider,
|
||||
@@ -26,11 +74,18 @@ impl Executor {
|
||||
}
|
||||
break (n, TokenOrigin::from(&t));
|
||||
}
|
||||
Meaning::Primitive(Primitive::Udelimiter) => {
|
||||
let class = self.integer(files)?;
|
||||
if !(0..=7).contains(&class) {
|
||||
return self.fail("Bad math class");
|
||||
}
|
||||
break (self.scan_extended_delimiter_code(files)?, TokenOrigin::from(&t));
|
||||
}
|
||||
Meaning::Character(TokenKind::Character(c, CatCode::Letter | CatCode::Other)) => {
|
||||
let c = u8::try_from(c as u32)
|
||||
.map_err(|_| self.error("delimiter character must be in 0..255", t.span))?;
|
||||
self.reads.insert(Dependency::DelCode(c));
|
||||
break (self.state.delcode(c), TokenOrigin::from(&t));
|
||||
if self.state.input_profile() != InputProfile::XeTeX && c as u32 > 255 {
|
||||
return Err(self.error("delimiter character must be in 0..255", t.span));
|
||||
}
|
||||
break (self.read_delimiter_code(c as u32), TokenOrigin::from(&t));
|
||||
}
|
||||
_ => return self.fail("expected native delimiter character or delimiter code"),
|
||||
}
|
||||
@@ -569,8 +624,8 @@ impl Executor {
|
||||
self.math.last_mut().unwrap().nodes.push(MathNode::Rule(r));
|
||||
}
|
||||
Left | Right => self.left_right(*p == Left, token.span, files)?,
|
||||
Umathchar | Umathcharnum => {
|
||||
let code = self.scan_unicode_math_code(*p == Umathchar, files)?;
|
||||
Umathchar | Umathcharnum | Udelimiter => {
|
||||
let code = self.scan_unicode_math_code(*p != Umathcharnum, files)?;
|
||||
let (class, c) = self.explicit_math_code(code)?;
|
||||
self.accept_math_field(MathField::Char(c), class, TokenOrigin::from(token));
|
||||
}
|
||||
@@ -616,11 +671,16 @@ impl Executor {
|
||||
let b = self.math.last_mut().unwrap();
|
||||
b.pending = Some(FieldTarget::Nucleus(b.nodes.len() - 1));
|
||||
}
|
||||
Radical => {
|
||||
let code = self.integer(files)?;
|
||||
if !(0..1 << 27).contains(&code) {
|
||||
return self.fail("radical must be in 0..134217727");
|
||||
}
|
||||
Radical | Uradical => {
|
||||
let code = if *p == Uradical {
|
||||
self.scan_extended_delimiter_code(files)?
|
||||
} else {
|
||||
let code = self.integer(files)?;
|
||||
if !(0..1 << 27).contains(&code) {
|
||||
return self.fail("radical must be in 0..134217727");
|
||||
}
|
||||
code
|
||||
};
|
||||
let delimiter = math::Delimiter::from_code(code as u32);
|
||||
self.new_noad(NoadClass::Ord, MathField::Empty, token.span);
|
||||
let builder = self.math.last_mut().unwrap();
|
||||
@@ -798,7 +858,7 @@ impl Executor {
|
||||
| Umathchardef | Umathcharnumdef | Catcode
|
||||
| Lccode | Uccode | Lowercase | Uppercase | Hyphenation | Patterns | Mathcode
|
||||
| Umathcode | Umathcodenum
|
||||
| Delcode | Count | Countdef | Dimen | Dimendef | Skip | Skipdef | Muskip
|
||||
| Delcode | Udelcode | Udelcodenum | Count | Countdef | Dimen | Dimendef | Skip | Skipdef | Muskip
|
||||
| Muskipdef | Toks | Toksdef | Advance | Multiply | Divide | Read | Readline
|
||||
| Font | Fontdimen | Hyphenchar | Skewchar | Lpcode | Rpcode | Efcode | Pdffontexpand
|
||||
| Knbccode | Knaccode | Letterspacefont | Textfont | Scriptfont
|
||||
|
||||
Reference in new issue
Block a user