Enum texlang::types::CatCode

source ·
pub enum CatCode {
Show 16 variants Escape = 0, BeginGroup = 1, EndGroup = 2, MathShift = 3, AlignmentTab = 4, EndOfLine = 5, Parameter = 6, Superscript = 7, Subscript = 8, Ignored = 9, Space = 10, Letter = 11, Other = 12, Active = 13, Comment = 14, Invalid = 15,
}
Expand description

Enum representing all 16 category codes in TeX.

Each variant’s documentation contains an example character which is mapped to that category code in plainTeX.

Variants§

§

Escape = 0

Marks the beginning of a control sequence. Example: \.

This category code is never seen outside of the lexer.

§

BeginGroup = 1

Begins a new group. Example: {.

§

EndGroup = 2

Ends an existing new group. Example: }.

§

MathShift = 3

Starts or ends math mode. Example: $.

§

AlignmentTab = 4

Used in typesetting tables to align cells. Example: &.

§

EndOfLine = 5

Marks a new line in the input. Example: \n.

This code behaves similarly to Space, but has two additional properties. First, two or more consecutive new lines, modulo intervening Space characters, create a \par control sequence instead of a regular space. Second, this code terminates a comment that started with a Comment character.

This category code is never seen outside of the lexer.

§

Parameter = 6

Marks the beginning of a parameter number. It must generally be followed by a digit. Example: #.

§

Superscript = 7

Puts following character or group in a superscript. Example: ^.

§

Subscript = 8

Puts following character or group in a subscript. Example: _.

§

Ignored = 9

Character that is ignored by the lexer. Example: ASCII null (0).

This category code is never seen outside of the lexer.

§

Space = 10

Whitespace. Example: .

§

Letter = 11

A character that can be used as a control sequence name. Examples: [a-zA-z].

§

Other = 12

A character than cannot be used as a control sequence name. Example: @.

§

Active = 13

A single character that behaves like a control sequence. Example: ~.

§

Comment = 14

Marks the beginning of a comment. All characters until the next EndOfLine are ignored. Example: %.

This category code is never seen outside of the lexer.

§

Invalid = 15

An invalid character. If this is encountered in the input, the lexer will return an error. Example: ASCII delete (127).

This category code is never seen outside of the lexer.

Implementations§

source§

impl CatCode

source

pub const INITEX_DEFAULTS: [CatCode; 128] = _

Default category codes in INITEX for all ASCII characters.

To find the category code for an ASCII character, convert it to an integer and use it as an index for the array.

This list was compiled by reading the source code TeX ’82, specifically section 232 in the “TeX: the program”. These defaults are also described in the TeXBook p343.

source

pub const PLAIN_TEX_DEFAULTS: [CatCode; 128] = _

Default category codes in plainTeX for all ASCII characters.

To find the category code for an ASCII character, convert it to an integer and use it as an index for the array.

This list was compiled by starting with INITEX_DEFAULTS and then applying all category code changes in the plainTeX format. These changes are described on p343 of the TeXBook.

Trait Implementations§

source§

impl Clone for CatCode

source§

fn clone(&self) -> CatCode

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CatCode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CatCode

source§

fn default() -> CatCode

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for CatCode

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for CatCode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S: TexlangState> Parsable<S> for CatCode

source§

fn parse_impl(input: &mut ExpandedStream<S>) -> Result<Self>

Parses a value from the vm::ExpandedStream.
source§

fn parse<I>(input: &mut I) -> Result<Self>
where I: AsMut<ExpandedStream<S>>,

Parses a value from an input stream. Read more
source§

impl PartialEq for CatCode

source§

fn eq(&self, other: &CatCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for CatCode

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl SupportedType for CatCode

source§

fn new_command<S>( ref_fn: RefFn<S, Self>, ref_mut_fn: MutRefFn<S, Self>, index_resolver: Option<IndexResolver<S>>, ) -> Command<S>

Create a new command of this type with the provided reference functions and index resolver.
source§

fn update_save_stack<S>( input: &mut ExecutionInput<S>, variable: &TypedVariable<S, Self>, scope: Scope, overwritten_value: Self, )

Update the VM’s save stack after a variable assignment.
source§

fn new_typed_variable<S>( command: &Command<S>, index: Index, ) -> Option<TypedVariable<S, Self>>

Create a new typed variable of this type from the getters in the command and the provided index. Read more
source§

fn try_cast<S>( command: &Command<S>, ) -> Option<(RefFn<S, Self>, MutRefFn<S, Self>)>

Try to cast a variable command to this type.
source§

fn recycle<S>(input: &mut ExecutionInput<S>, overwritten_value: Self)

Recycle a value that’s about to be dropped. Read more
source§

impl TryFrom<u8> for CatCode

source§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for CatCode

source§

impl Eq for CatCode

source§

impl StructuralPartialEq for CatCode

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,