org.extex.unit.tex.macro
Class Csname

java.lang.Object
  extended by org.extex.interpreter.type.AbstractCode
      extended by org.extex.unit.tex.macro.Csname
All Implemented Interfaces:
java.io.Serializable, Code, ExpandableCode, PrefixCode

public class Csname
extends AbstractCode
implements ExpandableCode, PrefixCode

This class provides an implementation for the primitive \csname.

The Primitive \csname

The primitive \csname absorbs further tokens until a matching \endcsname is found. The tokens found are expanded. Spaces are ignored. The expansion should lead to character tokens only. No primitives producing something different are allowed. A new token is constructed from the characters. The escape character is the current escape character.

If the meaning of the new token is currently not defined then it is defined to be equivalent to the original meaning of \relax.

If a non-expandable token is encountered then an error is raised.

Syntax

The formal description of this primitive is the following:
    ⟨csname⟩
      → \csname ⟨expandable tokens⟩ \endcsname  

Examples

    \csname abc\endcsname  

This results in the control sequence \abc.

    \csname ab#de\endcsname  

The example is valid. It shows that even non-character tokens might be contained.

    \csname \TeX\endcsname  

This is usually illegal since \TeX is defined in plain to contain some non-expandable primitives.

Version:
$Revision: 4770 $
Author:
Gerd Neugebauer
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
Csname(CodeToken token)
          Creates a new object.
 
Method Summary
 void execute(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens.
 void expand(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method takes the first token and expands it.
static java.lang.String scanToEndCsname(Context context, TokenSource source, Typesetter typesetter, Localizer loc)
          Expand tokens and collect the result until \endcsname is found.
 
Methods inherited from class org.extex.interpreter.type.AbstractCode
getLocalizer, getName, getToken, isIf, isOuter, readResolve, toString, toText, toText
 
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

Csname

public Csname(CodeToken token)
Creates a new object.

Parameters:
token - the initial token for the primitive
Method Detail

scanToEndCsname

public static java.lang.String scanToEndCsname(Context context,
                                               TokenSource source,
                                               Typesetter typesetter,
                                               Localizer loc)
                                        throws HelpingException,
                                               ConfigurationException,
                                               TypesetterException
Expand tokens and collect the result until \endcsname is found. In fact the termination condition is that a Token is found which is assigned to Endcsname.

Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
loc - the localizer
Returns:
the Tokens found while scanning the input tokens
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
ConfigurationException - in case of an configuration error

execute

public void execute(Flags prefix,
                    Context context,
                    TokenSource source,
                    Typesetter typesetter)
             throws HelpingException,
                    TypesetterException
This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens.

Specified by:
execute in interface Code
Overrides:
execute in class AbstractCode
Parameters:
prefix - the prefix controlling the execution
context - the interpreter context
source - the token source
typesetter - the typesetter
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
Code.execute( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

expand

public void expand(Flags prefix,
                   Context context,
                   TokenSource source,
                   Typesetter typesetter)
            throws HelpingException,
                   ConfigurationException,
                   TypesetterException
This method takes the first token and expands it. The result is placed on the stack. This means that expandable code does one step of expansion and puts the result on the stack. To expand a token it might be necessary to consume further tokens.

Specified by:
expand in interface ExpandableCode
Parameters:
prefix - the prefix flags controlling the expansion
context - the interpreter context
source - the token source
typesetter - the typesetter
Throws:
HelpingException - in case of an error
ConfigurationException - in case of an configuration error
TypesetterException - in case of an error in the typesetter
See Also:
ExpandableCode.expand( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)