Enum texlang::types::CatCode

source ·
pub enum CatCode {
Show 16 variants Escape, BeginGroup, EndGroup, MathShift, AlignmentTab, EndOfLine, Parameter, Superscript, Subscript, Ignored, Space, Letter, Other, Active, Comment, Invalid,
}
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

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

This category code is never seen outside of the lexer.

§

BeginGroup

Begins a new group. Example: {.

§

EndGroup

Ends an existing new group. Example: }.

§

MathShift

Starts or ends math mode. Example: $.

§

AlignmentTab

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

§

EndOfLine

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

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

§

Superscript

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

§

Subscript

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

§

Ignored

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

This category code is never seen outside of the lexer.

§

Space

Whitespace. Example: .

§

Letter

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

§

Other

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

§

Active

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

§

Comment

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

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, Box<Error>>

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

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

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

impl PartialEq<CatCode> for CatCode

source§

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

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

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

This method 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 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

§

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 StructuralEq for CatCode

source§

impl StructuralPartialEq for CatCode

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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 Twhere T: for<'de> Deserialize<'de>,