org.extex.unit.tex.register
Class CatcodePrimitive
java.lang.Object
org.extex.interpreter.type.AbstractCode
org.extex.interpreter.type.AbstractAssignment
org.extex.unit.tex.register.CatcodePrimitive
- All Implemented Interfaces:
- java.io.Serializable, CountConvertible, Code, 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.
| ESCAPE |
0 |
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. |
| LEFTBRACE |
1 |
This character is a left brace. It is used for grouping. |
| RIGHTBRACE |
2 |
This character is a right brace. It is used for grouping. |
| MATHSHIFT |
3 |
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. |
| TABMARK |
4 |
|
| CR |
5 |
|
| MACROPARAM |
6 |
This character is a macro parameter. It is meaningful under certain
circumstances only. |
| SUPMARK |
7 |
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. |
| SUBMARK |
8 |
This character is an indicator the the following material should be
typeset as subscript. It is meaningful in math mode only. |
| IGNORE |
9 |
This character is ignored during paring. It is dropped silently. |
| SPACE |
10 |
This character is a white-space character. It is treated as if a simple
space has been found. Under some circumstances it is ignored. |
| LETTER |
11 |
This character is a letter. As such it can be part of an escape
sequence. |
| OTHER |
12 |
This character is another simple character which is not a letter. |
| ACTIVE |
13 |
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. |
| COMMENT |
14 |
This character signals the beginning of a comment. The comment reaches
to the end of the current line. |
| INVALID |
15 |
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: 4770 $
- Author:
- Gerd Neugebauer, Michael Niedermair
- See Also:
- Serialized Form
|
Field Summary |
protected static long |
serialVersionUID
The constant serialVersionUID contains the id for
serialization. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
serialVersionUID
protected static final long serialVersionUID
- The constant serialVersionUID contains the id for
serialization.
- See Also:
- Constant Field Values
CatcodePrimitive
public CatcodePrimitive(CodeToken token)
- Creates a new object.
- Parameters:
token - the initial token for the primitive
assign
public void assign(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
- 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 executioncontext - the interpreter contextsource - the token sourcetypesetter - the typesetter
- Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter- See Also:
AbstractAssignment.assign(
org.extex.interpreter.Flags, org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
convertCount
public long convertCount(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
- 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 contextsource - the source for new tokenstypesetter - the typesetter to use for conversion
- Returns:
- the converted value
- Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter- See Also:
CountConvertible.convertCount(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
the
public Tokens the(Context context,
TokenSource source,
Typesetter typesetter)
throws CatcodeException,
HelpingException,
TypesetterException
- This method is the getter for the description of the primitive.
- Specified by:
the in interface Theable
- Parameters:
context - the interpreter contextsource - the source for further tokens to qualify the requesttypesetter - the typesetter to use
- Returns:
- the description of the primitive as list of Tokens
- Throws:
CatcodeException - in case of an error in token creation
HelpingException - in case of an error
TypesetterException - in case of an error- See Also:
Theable.the(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)