de.dante.extex.interpreter.primitives.register
Class CatcodePrimitive

java.lang.Object
  extended byde.dante.extex.interpreter.type.AbstractCode
      extended byde.dante.extex.interpreter.type.AbstractAssignment
          extended byde.dante.extex.interpreter.primitives.register.CatcodePrimitive
All Implemented Interfaces:
Code, CountConvertible, Localizable, java.io.Serializable, Theable

public class CatcodePrimitive
extends AbstractAssignment
implements CountConvertible, Theable

This class provides an implementation for the primitive \catcode.

The Primitive \catcode

The primitive \catcode can be used to influence the tokenizer of ExTeX. This is done by assigning category codes to single characters. Whenever characters are read tokens are generated and passed on. Those tokens carry the category code into the interpreter. The interpreter considers always tokens, i.e. characters and category codes. Thus the same character can be treated differently depending on the catcode of the token.

The assignment of a catcode for a character is controlled by the prefix primitive \global and the count parameter \globaldefs. Usually the assignment is acting on the current group only. If the count parameter \globaldefs is greater than 0 or the prefix \global is given then the assignment is applied to all groups.

The following table contains the category codes with their meaning and the mapping to numerical values.

ESCAPE0 This character code signals the beginning of an escape sequence. The following letters are absorbed into the name. If the following token is not a letter then only this single character is absorbed.
LEFTBRACE1 This character is a left brace. It is used for grouping.
RIGHTBRACE2 This character is a right brace. It is used for grouping.
MATHSHIFT3 This character is used to switch to math mode. A single one switches to inline math mode and a double one to display math mode.
TABMARK4
CR5
MACROPARAM6 This character is a macro parameter. It is meaningful under certain circumstances only.
SUPMARK7 This character is an indicator the the following material should be typeset as superscript. It is meaningful in math mode only. This character class is used to parse characters from their code point as well.
SUBMARK8 This character is an indicator the the following material should be typeset as subscript. It is meaningful in math mode only.
IGNORE9 This character is ignored during paring. It is dropped silently.
SPACE10 This character is a white-space character. It is treated as if a simple space has been found. Under some circumstances it is ignored.
LETTER11 This character is a letter. As such it can be part of an escape sequence.
OTHER12 This character is another simple character which is not a letter.
ACTIVE13 This character is an active character. This means that some code could be bound to it. Active characters do not need the leading escape symbol like escape sequences.
COMMENT14 This character signals the beginning of a comment. The comment reaches to the end of the current line.
INVALID15 This character is invalid and will be dropped.

Syntax

The formal description of this primitive is the following:
    ⟨catcode⟩
      → ⟨optional prefix⟩ \catcode ⟨8-bit number⟩ ⟨equals⟩ ⟨4-bit number⟩

    ⟨optional prefix⟩
      →
       |  ⟨global⟩ ⟨optional prefix⟩  

Examples

    \catcode `\%=12  
    \global\catcode `\%=11  

\catcode as a Count Value

\catcode can be used wherever a count value is required.

Version:
$Revision: 1.31 $
Author:
Gerd Neugebauer, Michael Niedermair
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
CatcodePrimitive(java.lang.String name)
          Creates a new object.
 
Method Summary
 void assign(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          The method assign is the core of the functionality of execute().
 long convertCount(Context context, TokenSource source, Typesetter typesetter)
          This method converts a register into a count.
 Tokens the(Context context, TokenSource source, Typesetter typesetter)
          This method is the getter for the description of the primitive.
 
Methods inherited from class de.dante.extex.interpreter.type.AbstractAssignment
execute
 
Methods inherited from class de.dante.extex.interpreter.type.AbstractCode
enableLocalization, getLocalizer, getName, isIf, isOuter, printable, printableControlSequence, readResolve, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values
Constructor Detail

CatcodePrimitive

public CatcodePrimitive(java.lang.String name)
Creates a new object.

Parameters:
name - the name for debugging
Method Detail

assign

public void assign(Flags prefix,
                   Context context,
                   TokenSource source,
                   Typesetter typesetter)
            throws InterpreterException
Description copied from class: AbstractAssignment
The method assign is the core of the functionality of execute(). This method is preferable to execute() since the execute() method provided in this class takes care of \afterassignment and \globaldefs as well.

Specified by:
assign in class AbstractAssignment
Parameters:
prefix - the prefix controlling the execution
context - the interpreter context
source - the token source
typesetter - the typesetter
Throws:
InterpreterException - in case of an error
See Also:
Code.execute( de.dante.extex.interpreter.Flags, de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource, de.dante.extex.typesetter.Typesetter)

convertCount

public long convertCount(Context context,
                         TokenSource source,
                         Typesetter typesetter)
                  throws InterpreterException
Description copied from interface: CountConvertible
This method converts a register into a count. It might be necessary to read further tokens to determine which value to use. For instance an additional register number might be required. In this case the additional arguments Context and TokenSource can be used.

Specified by:
convertCount in interface CountConvertible
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter to use for conversion
Returns:
the converted value
Throws:
InterpreterException - in case of an error
See Also:
CountConvertible.convertCount( de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource, de.dante.extex.typesetter.Typesetter)

the

public Tokens the(Context context,
                  TokenSource source,
                  Typesetter typesetter)
           throws InterpreterException
Description copied from interface: Theable
This method is the getter for the description of the primitive.

Specified by:
the in interface Theable
Parameters:
context - the interpreter context
source - the source for further tokens to qualify the request
typesetter - the typesetter to use
Returns:
the description of the primitive as list of Tokens
Throws:
InterpreterException - in case of an error
See Also:
Theable.the( de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource, de.dante.extex.typesetter.Typesetter)