|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.extex.interpreter.type.AbstractCode
org.extex.unit.etex.register.count.Numexpr
public class Numexpr
This class provides an implementation for the primitive
The primitive \numexpr provides a means to use a inline way of
writing mathematical expressions to be evaluated. Mathematical expressions
can be evaluated in
The mathematical expression to be evaluated can be made up of the basic
operations addition (+), subtraction (-), multiplication (*), and
division(/). The unary minus can be used. Parentheses can be used for
grouping. Anything which looks like a number can be used as argument.
White-space can be used freely without any harm.
The expression is terminated at the first token which can not be part of an
expression. For instance a letter may signal the end of the expression. If
the expression should terminate without a proper token following it, the
token \relax can be used to signal the end of the expression. This
\relax token is silently consumed by \numexpr.
The primitive \numexpr can be used in any place where a number is
required. This includes assignments to count registers and comparisons.
\numexpr.
The Primitive \numexpr
Syntax
The formal description of this primitive is the following:
〈numexpr〉
→ \numexpr 〈expr〉 \relax
| \numexpr 〈expr〉
〈expr〉
→ 〈number〉
| 〈operand〉
| 〈expr〉 + 〈expr〉
| 〈expr〉 - 〈expr〉
| 〈expr〉 * 〈expr〉
| 〈expr〉 / 〈expr〉
〈operand〉
→ 〈number〉
| - 〈expr〉
| ( 〈expr〉 )
Examples
\count1=\numexpr 23 \relax
\count1=\numexpr 2 * 3 \relax
\count1=\numexpr 2*\count2
\count1=\numexpr 2*(1+3)
\count1=\numexpr 2*-\count0
| Field Summary | |
|---|---|
protected static long |
serialVersionUID
The constant serialVersionUID contains the id for serialization. |
| Constructor Summary | |
|---|---|
Numexpr(CodeToken token)
Creates a new object. |
|
| Method Summary | |
|---|---|
long |
convertCount(Context context,
TokenSource source,
Typesetter typesetter)
This method converts a register into a count. |
long |
evalOperand(Context context,
TokenSource source,
Typesetter typesetter)
Evaluate an operand. |
Tokens |
the(Context context,
TokenSource source,
Typesetter typesetter)
This method is the getter for the description of the primitive. |
| Methods inherited from class org.extex.interpreter.type.AbstractCode |
|---|
execute, 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 |
|---|
protected static final long serialVersionUID
| Constructor Detail |
|---|
public Numexpr(CodeToken token)
token - the initial token for the primitive| Method Detail |
|---|
public long convertCount(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
convertCount in interface CountConvertiblecontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetter to use for conversion
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterCountConvertible.convertCount(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
public long evalOperand(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
context - the interpreter contextsource - the source for new tokenstypesetter - the typesetter
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
public Tokens the(Context context,
TokenSource source,
Typesetter typesetter)
throws CatcodeException,
HelpingException,
TypesetterException
the in interface Theablecontext - the interpreter contextsource - the source for further tokens to qualify the requesttypesetter - the typesetter to use
CatcodeException - in case of an error in token creation
ConfigurationException - in case of an configuration error
HelpingException - in case of an error
TypesetterException - in case of an errorTheable.the(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||