|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.dante.extex.interpreter.type.AbstractCode
de.dante.extex.interpreter.primitives.conditional.AbstractIf
de.dante.extex.interpreter.primitives.conditional.Ifcase
This class provides an implementation for the primitive
The primitive \ifcase provides a conditional switch on a numeric
value. The next tokens are used as a number. This number determines which
branch to expand. The first branch follows the number immediately. This
branch is associated to the number 0.
The primitive \or advances to the next branch.
The primitive \else starts the else branch. The else branch is used
if no other branch fits.
\ifcase
.
The Primitive \ifcase
Syntax
The formal description of this primitive is the following:
〈ifcase〉
→ \ifcase 〈number〉 〈cases〉 \fi
〈cases〉
→
| 〈branch text〉 \else 〈else text〉
| 〈branch text〉 \or 〈cases〉
Examples
\ifcase\count0 a\or b\or c\else x\fi
Nested Class Summary | |
protected static class |
Ifcase.Tag
This is an internal class for type-safe values. |
Field Summary | |
protected static Ifcase.Tag |
ELSE
The constant ELSE contains the value indicating an \else. |
protected static Ifcase.Tag |
FI
The constant FI contains the value indicating a \fi. |
protected static Ifcase.Tag |
OR
The constant OR contains the value indicating an \or. |
protected static long |
serialVersionUID
The constant serialVersionUID contains the id for serialization. |
Constructor Summary | |
Ifcase(java.lang.String name)
Creates a new object. |
Method Summary | |
protected boolean |
conditional(Context context,
TokenSource source,
Typesetter typesetter)
This method computes the boolean value of the conditional. |
void |
execute(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
This method takes the first token and executes it. |
void |
expand(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
This method takes the first token and expands it. |
Methods inherited from class de.dante.extex.interpreter.primitives.conditional.AbstractIf |
getMyLocalizer, isIf, skipToElseOrFi |
Methods inherited from class de.dante.extex.interpreter.type.AbstractCode |
enableLocalization, getLocalizer, getName, 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 |
protected static final long serialVersionUID
protected static final Ifcase.Tag OR
protected static final Ifcase.Tag ELSE
protected static final Ifcase.Tag FI
Constructor Detail |
public Ifcase(java.lang.String name)
name
- the name for debuggingMethod Detail |
public void execute(Flags prefix, Context context, TokenSource source, Typesetter typesetter) throws InterpreterException
Code
execute
in interface Code
execute
in class AbstractIf
InterpreterException
Code.execute(
de.dante.extex.interpreter.Flags,
de.dante.extex.interpreter.context.Context,
de.dante.extex.interpreter.TokenSource,
de.dante.extex.typesetter.Typesetter)
public void expand(Flags prefix, Context context, TokenSource source, Typesetter typesetter) throws InterpreterException
ExpandableCode
expand
in interface ExpandableCode
expand
in class AbstractIf
InterpreterException
ExpandableCode.expand(
de.dante.extex.interpreter.Flags,
de.dante.extex.interpreter.context.Context,
de.dante.extex.interpreter.TokenSource,
de.dante.extex.typesetter.Typesetter)
protected boolean conditional(Context context, TokenSource source, Typesetter typesetter)
AbstractIf
true
then the then branch is expanded and
the else branch is skipped. Otherwise the then branch is skipped and the
else branch is expanded.
conditional
in class AbstractIf
context
- the interpreter contextsource
- the source for new tokenstypesetter
- the typesetter
AbstractIf.conditional(
de.dante.extex.interpreter.context.Context,
de.dante.extex.interpreter.TokenSource,
de.dante.extex.typesetter.Typesetter)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |