|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.extex.interpreter.max.Max
org.extex.interpreter.max.Moritz
public class Moritz
This class provides the layer above the input streams and the tokenizer. It has additional methods for parsing. The details of the token streams are mostly hidden.
This class is the companion to Max. (The name is a joke for friends of Wilhelm Busch)
The integer register \maxRegister controls the scanning of register names. The following interpretation for the values is used:
The integer register \max.register is not affected by grouping. This means that any assignment is always global.
The primitive \maxRegister is usually defined in the name space system. Thus you have to take special means to access it.
{\namespace{system}\maxRegister=1024}
| Constructor Summary | |
|---|---|
Moritz()
Creates a new object. |
|
| Method Summary | |
|---|---|
void |
addStream(TokenStream theStream)
Put a given stream on top of the stream stack. |
void |
closeAllStreams(Context context)
All input streams are closed and not further Token is available for processing. |
void |
closeNextFileStream(Context context)
Close all streams on the stack until a file stream is found. |
Box |
getBox(Flags flags,
Context context,
Typesetter typesetter,
Token insert)
Parse the specification of a box. |
CodeToken |
getControlSequence(Context context,
Typesetter typesetter)
Get the next token from the token stream and check that it is a control sequence or active character. |
Font |
getFont(Context context,
CodeToken primitive)
Parse the specification of a font. |
boolean |
getKeyword(Context context,
java.lang.String s)
Scan the expanded token stream for a sequence of letter tokens. |
Token |
getLastToken()
Getter for the token just previously read from the token source. |
Locator |
getLocator()
Getter for the locator. |
Token |
getNonSpace(Context context)
Get the next token which has not the category code SPACE. |
long |
getNumber(Token token)
Scan a number with a given first token. |
void |
getOptionalEquals(Context context)
Skip spaces and if the next non-space character is an equal sign skip it as well and all spaces afterwards. |
Token |
getToken(Context context)
Get the next token from the input streams. |
Tokens |
getTokens(Context context,
TokenSource source,
Typesetter typesetter)
Get the next tokens form the input streams between { and
}. |
TokenStreamFactory |
getTokenStreamFactory()
Getter for the token stream factory. |
java.lang.Object |
parse(java.lang.Class c,
Context context,
TokenSource source,
Typesetter typesetter)
Parse some data type. |
Dimen |
parseDimen(Context context,
TokenSource source,
Typesetter typesetter)
Acquire a length value and return it in multiples of scaled points. |
Glue |
parseGlue(Context context,
TokenSource source,
Typesetter typesetter)
Parse a glue value and return the result. |
long |
parseInteger(Context context,
TokenSource source,
Typesetter typesetter)
Parse an integer. |
long |
parseNumber(Context context,
TokenSource source,
Typesetter typesetter)
Parse a non-negative number. |
void |
push(Token token)
Push back a token onto the input stream for subsequent reading. |
void |
push(Token[] tokens)
Push back a list of tokens onto the input stream for subsequent reading. |
void |
push(Tokens tokens)
Push back a list of tokens onto the input stream for subsequent reading. |
Parser |
register(java.lang.Class c,
Parser p)
Register a new parser for some data type. |
void |
registerObserver(EofObserver observer)
Add an observer for the eof event. |
void |
registerObserver(OpenFileObserver observer)
Register an open file observer for later use. |
void |
registerObserver(OpenReaderObserver observer)
Register an open reader observer for later use. |
void |
registerObserver(OpenStringObserver observer)
Register an open string observer for later use. |
void |
registerObserver(PopObserver observer)
Add an observer for the pop event. |
void |
registerObserver(PushObserver observer)
Add an observer for the push event. |
void |
registerObserver(StreamCloseObserver observer)
Register an stream close observer for later use. |
UnicodeChar |
scanCharacterCode(Context context,
Typesetter typesetter,
CodeToken primitive)
Scan the input stream for tokens making up a character code, this is a sequence of digits with category code OTHER. |
Token |
scanNonSpace(Context context)
Scan the input for the next token which has not the category code SPACE. |
java.lang.String |
scanRegisterName(Context context,
TokenSource source,
Typesetter typesetter,
CodeToken primitive)
Scan the input streams for an entity to denote a register name. |
Token |
scanToken(Context context)
Get the next expanded token form the input streams. |
Tokens |
scanTokens(Context context,
boolean reportUndefined,
boolean ignoreUndefined,
CodeToken primitive)
Get the next expanded token form the input streams between {
and }. |
java.lang.String |
scanTokensAsString(Context context,
CodeToken primitive)
Get the next expanded tokens from the input streams between a left brace character (usually {) and a right brace character
(usually }) and convert it to a String. |
Tokens |
scanUnprotectedTokens(Context context,
boolean reportUndefined,
boolean ignoreUndefined,
CodeToken primitive)
Get the next expanded tokens from the input streams between { and }. |
void |
setTokenStreamFactory(TokenStreamFactory factory)
Setter for the token stream factory. |
void |
skipSpace()
Skip spaces and check whether any tokens are left. |
java.lang.String |
toString()
|
void |
update(java.lang.String name,
java.lang.String text)
Send the string to the named observer. |
| Methods inherited from class org.extex.interpreter.max.Max |
|---|
configure, enableLogging, execute, executeGroup, expand, expand, expand, expandUnproteced, getContext, getErrorHandler, getInteraction, getLocalizer, getLogger, getTypesetter, initializeDate, loadFormat, loadUnit, registerObserver, registerObserver, registerObserver, registerObserver, registerObserver, registerObserver, registerObserver, run, run, setContext, setErrorHandler, setFontFactory, setInteraction, setJobname, setOutputStreamFactory, setTypesetter, visitActive, visitCr, visitEscape, visitLeftBrace, visitLetter, visitMacroParam, visitMathShift, visitOther, visitRightBrace, visitSpace, visitSubMark, visitSupMark, visitTabMark |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.extex.interpreter.TokenSource |
|---|
execute, executeGroup, expand, expand |
| Methods inherited from interface org.extex.framework.configuration.Configurable |
|---|
configure |
| Constructor Detail |
|---|
public Moritz()
| Method Detail |
|---|
public void addStream(TokenStream theStream)
addStream in interface TokenSourcetheStream - the new stream to read fromTokenSource.addStream(
org.extex.scanner.api.TokenStream)
public void closeAllStreams(Context context)
throws HelpingException
closeAllStreams in interface TokenSourcecontext - the interpreter context
HelpingException - in case of an errorTokenSource.closeAllStreams(
org.extex.interpreter.context.Context)
public void closeNextFileStream(Context context)
throws HelpingException
closeNextFileStream in interface TokenSourcecontext - the interpreter context
HelpingException - in case of an errorTokenSource.closeNextFileStream(
org.extex.interpreter.context.Context)
public Box getBox(Flags flags,
Context context,
Typesetter typesetter,
Token insert)
throws HelpingException,
TypesetterException
getBox in interface TokenSourceflags - the flags to be restoredcontext - the interpreter contexttypesetter - the typesetter to useinsert - the token to insert either at the beginning of the box or
after the box has been gathered. If it is null then
nothing is inserted
HelpingException - in case of an error
ConfigurationException - in case of an configuration error
TypesetterException - in case of an error in the typesetterTokenSource.getBox(
org.extex.interpreter.Flags, org.extex.interpreter.context.Context,
org.extex.typesetter.Typesetter, org.extex.scanner.type.token.Token)
public CodeToken getControlSequence(Context context,
Typesetter typesetter)
throws HelpingException
null.
getControlSequence in interface TokenSourcecontext - the interpreter contexttypesetter - the typesetter
HelpingException - in case that the token stream is at its end or
that the token read is not a control sequence tokenTokenSource.getControlSequence(
org.extex.interpreter.context.Context,
org.extex.typesetter.Typesetter)
public Font getFont(Context context,
CodeToken primitive)
throws HelpingException,
TypesetterException
TokenSourceThis method parses the following syntactic entity:
〈font〉
getFont in interface TokenSourcecontext - the interpreter contextprimitive - the name of the primitive for error messages
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterTokenSource.getFont(
org.extex.interpreter.context.Context, CodeToken)
public boolean getKeyword(Context context,
java.lang.String s)
throws HelpingException
true is returned. Otherwise all tokens are left in the
input stream and false is returned.
getKeyword in interface TokenSourcecontext - the interpreter contexts - the tokens to scan
true iff the tokens could have been successfully
removed from the input stream
HelpingException - in case that no number is found or the end of
file has been reached before an integer could be acquiredpublic Token getLastToken()
TokenSource
getLastToken in interface TokenSourcenull if not availableTokenSource.getLastToken()public Locator getLocator()
TokenSource
getLocator in interface TokenSourceTokenSource.getLocator()
public Token getNonSpace(Context context)
throws HelpingException
SPACE.
getNonSpace in interface TokenSourcecontext - the interpreter context
null at EOF
HelpingException - in case of an errorTokenSource.getNonSpace(
org.extex.interpreter.context.Context)
public long getNumber(Token token)
throws HelpingException,
MissingNumberException
token - the first token to consider
HelpingException - in case that no number is found or the end of
file has been reached before an integer could be acquired
MissingNumberException - in case that no number is found or the end
of file has been reached before an integer could be acquired
public void getOptionalEquals(Context context)
throws HelpingException
getOptionalEquals in interface TokenSourcecontext - the interpreter context
HelpingException - in case of an errorTokenSource.getOptionalEquals(
org.extex.interpreter.context.Context)
public Token getToken(Context context)
throws HelpingException
null is
returned.
Whenever a file stream is closed then the tokens from the stream are discarded. This holds also for the tokens pushed back onto this stream.
getToken in interface TokenSourcecontext - the interpreter context
null
HelpingException - in case of an errorTokenSource.getToken(
org.extex.interpreter.context.Context)
public Tokens getTokens(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
{ and
}. If the current input stream is at its end then the
next one on the streamStack is used until a token could be read. If all
streams are at the end then an exception is thrown.
This method parses the following syntactic entity:
〈replacement text〉
getTokens in interface TokenSourcecontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetter
null
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterTokenSource.getTokens(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)public TokenStreamFactory getTokenStreamFactory()
getTokenStreamFactory in interface TokenSource
public java.lang.Object parse(java.lang.Class c,
Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
parse in interface TokenSourcec - the classcontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetter
null if at end of file
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterTokenSource.parse(java.lang.Class,
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
public Dimen parseDimen(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
parseDimen in interface DimenParsercontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetter
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterDimenParser.parseDimen(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
public Glue parseGlue(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
parseGlue in interface GlueParsercontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetter
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterGlueParser.parseGlue(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
public long parseInteger(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
parseInteger in interface CountParsercontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetter
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterCountParser.parseInteger(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
public long parseNumber(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
parseNumber in interface CountParsercontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetter
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterCountParser.parseNumber(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
public void push(Token token)
throws HelpingException
push in interface TokenSourcetoken - the token to push
HelpingException - in case of an errorTokenSource.push(
org.extex.scanner.type.token.Token)
public void push(Token[] tokens)
throws HelpingException
push in interface TokenSourcetokens - the tokens to push
HelpingException - in case of an errorTokenSource.push(
org.extex.scanner.type.token.Token[])
public void push(Tokens tokens)
throws HelpingException
null then it is silently
ignored.
push in interface TokenSourcetokens - the tokens to push
HelpingException - in case of an errorTokenSource.push(
org.extex.scanner.type.tokens.Tokens)
public Parser register(java.lang.Class c,
Parser p)
throws HelpingException
register in interface TokenSourcec - the classp - the parser for the class
null if none has
been registered
HelpingException - in case of an errorTokenSource.register(java.lang.Class,
org.extex.interpreter.parser.Parser)public void registerObserver(EofObserver observer)
registerObserver in interface EofObservableobserver - the observer to addpublic void registerObserver(OpenFileObserver observer)
registerObserver in interface OpenFileObservableobserver - the observer to be registeredOpenFileObservable.registerObserver(
org.extex.scanner.stream.observer.file.OpenFileObserver)public void registerObserver(OpenReaderObserver observer)
registerObserver in interface OpenReaderObservableobserver - the observer to be registeredOpenReaderObservable.registerObserver(
org.extex.scanner.stream.observer.reader.OpenReaderObserver)public void registerObserver(OpenStringObserver observer)
registerObserver in interface OpenStringObservableobserver - the observer to be registeredOpenStringObservable.registerObserver(
org.extex.scanner.stream.observer.string.OpenStringObserver)public void registerObserver(PopObserver observer)
registerObserver in interface PopObservableobserver - the observer to addpublic void registerObserver(PushObserver observer)
registerObserver in interface PushObservableobserver - the observer to addpublic void registerObserver(StreamCloseObserver observer)
registerObserver in interface StreamCloseObservableobserver - the observer to be registeredStreamCloseObservable.registerObserver(
org.extex.interpreter.observer.streamClose.StreamCloseObserver)
public UnicodeChar scanCharacterCode(Context context,
Typesetter typesetter,
CodeToken primitive)
throws HelpingException,
TypesetterException
This method parses the following syntactic entity:
〈character code〉
A character is a positive number.
Tokens are expanded while gathering the requested values.
scanCharacterCode in interface TokenSourcecontext - the interpreter contexttypesetter - the typesetterprimitive - the name of the invoking primitive for error handling
HelpingException - in case of an errorTypesetterException - in case of an error in the typesetterTokenSource.scanCharacterCode(
org.extex.interpreter.context.Context,
org.extex.typesetter.Typesetter, CodeToken)
public Token scanNonSpace(Context context)
throws HelpingException,
TypesetterException
scanNonSpace in interface TokenSourcecontext - the interpreter context
null at EOF
HelpingException - in case of an error in
scanToken()
TypesetterException - in case of an error in the typesetterTokenSource.scanNonSpace(
org.extex.interpreter.context.Context)
public java.lang.String scanRegisterName(Context context,
TokenSource source,
Typesetter typesetter,
CodeToken primitive)
throws HelpingException,
TypesetterException
TokenSourcenull is returned.
A register name determines under which key a register can be addressed.
In
The alternative is controlled by the integer register \maxregister. The following interpretation of the value of this count is used:
The value of the integer register \maxRegister is set
differently for various configurations of
Te integer register \maxRegister is defined in the name space system. Thus special actions have to be used to access it.
〈register name〉
→ 〈tokens〉
| 〈number〉
123
{abc}
scanRegisterName in interface TokenSourcecontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetterprimitive - the name of the invoking primitive for error handling
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterTokenSource.scanRegisterName(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter,
CodeToken)
public Token scanToken(Context context)
throws HelpingException,
TypesetterException
null
is returned.
scanToken in interface TokenSourcecontext - the interpreter context
null
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterTokenSource.scanToken(
org.extex.interpreter.context.Context)
public Tokens scanTokens(Context context,
boolean reportUndefined,
boolean ignoreUndefined,
CodeToken primitive)
throws HelpingException,
TypesetterException
{
and }. If the current input stream is at its end then the
next one on the streamStack is used until a token could be read. If all
stream are at the end then null is returned. Nevertheless
if some tokens could have been read before the end of file occurred then
those tokens are returned – even if no matching brace is found.
This method parses the following syntactic entity:
〈general text〉
scanTokens in interface TokenSourcecontext - the interpreter contextreportUndefined - indicator that an undefined control sequence leads
to an exception. This parameter is effective only if
ignoreUndefined is falseignoreUndefined - indicator that an undefined control sequence
should be treated as \relaxprimitive - the name of the invoking primitive for error handling
null under any circumstances
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterTokenSource.scanTokens(
org.extex.interpreter.context.Context, boolean, boolean,
org.extex.scanner.type.token.CodeToken)
public java.lang.String scanTokensAsString(Context context,
CodeToken primitive)
throws HelpingException,
TypesetterException
{) and a right brace character
(usually }) and convert it to a String.
If the end of file is reached then an Exception is raised.
scanTokensAsString in interface TokenSourcecontext - the interpreter contextprimitive - the name of the invoking primitive for error handling
String or null
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterTokenSource.scanTokensAsString(
org.extex.interpreter.context.Context, CodeToken)
public Tokens scanUnprotectedTokens(Context context,
boolean reportUndefined,
boolean ignoreUndefined,
CodeToken primitive)
throws HelpingException,
TypesetterException
{ and }. If the current input stream is at
its end then the next one on the streamStack is used until a token could
be read. If all stream are at the end then null is
returned.
Normally all expandable tokens are expanded. This method honors the protected mark and does not try to expand protected code.
scanUnprotectedTokens in interface TokenSourcecontext - the interpreter contextreportUndefined - indicator that an undefined control sequence leads
to an exception. This parameter is effective only if
ignoreUndefined is falseignoreUndefined - indicator that an undefined control sequence
should be treated as \relaxprimitive - the name of the invoking primitive for error handling
null
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterTokenSource.scanUnprotectedTokens(
org.extex.interpreter.context.Context, boolean, boolean, CodeToken)public void setTokenStreamFactory(TokenStreamFactory factory)
setTokenStreamFactory in interface Interpreterfactory - the token stream factory
ConfigurationException - this exception is never thrown. It is
defined here to provide an exit for derived classespublic void skipSpace()
skipSpace in interface TokenSourceTokenSource.skipSpace()public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()
public void update(java.lang.String name,
java.lang.String text)
throws NotObservableException
update in interface TokenSourcename - name of the observertext - the text to send to the observer
NotObservableException - in case that the named observer is not
accessibleTokenSource.update(java.lang.String,
java.lang.String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||