org.extex.interpreter.max
Class Moritz

java.lang.Object
  extended by org.extex.interpreter.max.Max
      extended by org.extex.interpreter.max.Moritz
All Implemented Interfaces:
OutputStreamConsumer, Configurable, LogEnabled, Interpreter, CommandObservable, EofObservable, ErrorObservable, ExpandObservable, ExpandMacroObservable, LoadObservable, PopObservable, PushObservable, StartObservable, StopObservable, StreamCloseObservable, CountParser, DimenParser, GlueParser, TokenSource, OpenFileObservable, OpenReaderObservable, OpenStringObservable, TokenVisitor<java.lang.Object,java.lang.Object>
Direct Known Subclasses:
StringSource

public class Moritz
extends Max
implements TokenSource, Configurable, StreamCloseObservable, PopObservable, PushObservable, EofObservable, OpenFileObservable, OpenStringObservable, OpenReaderObservable

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

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.

Examples

   {\namespace{system}\maxRegister=1024}  

Version:
$Revision:4408 $
Author:
Gerd Neugebauer, Michael Niedermair

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

Moritz

public Moritz()
Creates a new object.

Method Detail

addStream

public void addStream(TokenStream theStream)
Put a given stream on top of the stream stack. The reading occurs on this new stream before resorting to the previous streams.

Specified by:
addStream in interface TokenSource
Parameters:
theStream - the new stream to read from
See Also:
TokenSource.addStream( org.extex.scanner.api.TokenStream)

closeAllStreams

public void closeAllStreams(Context context)
                     throws HelpingException
All input streams are closed and not further Token is available for processing. This normally means that the interpreter is forced to terminate more or less gracefully.

Specified by:
closeAllStreams in interface TokenSource
Parameters:
context - the interpreter context
Throws:
HelpingException - in case of an error
See Also:
TokenSource.closeAllStreams( org.extex.interpreter.context.Context)

closeNextFileStream

public void closeNextFileStream(Context context)
                         throws HelpingException
Close all streams on the stack until a file stream is found. This file stream is closed as last one. The other streams are left unchanged. If no file stream is found the all streams are closed and none is left.

Specified by:
closeNextFileStream in interface TokenSource
Parameters:
context - the interpreter context
Throws:
HelpingException - in case of an error
See Also:
TokenSource.closeNextFileStream( org.extex.interpreter.context.Context)

getBox

public Box getBox(Flags flags,
                  Context context,
                  Typesetter typesetter,
                  Token insert)
           throws HelpingException,
                  TypesetterException
Parse the specification of a box.

Specified by:
getBox in interface TokenSource
Parameters:
flags - the flags to be restored
context - the interpreter context
typesetter - the typesetter to use
insert - 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
Returns:
the box gathered
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:
TokenSource.getBox( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.typesetter.Typesetter, org.extex.scanner.type.token.Token)

getControlSequence

public CodeToken getControlSequence(Context context,
                                    Typesetter typesetter)
                             throws HelpingException
Get the next token from the token stream and check that it is a control sequence or active character. At the end of all input streams the control sequence "inaccessible" is inserted and an exception is thrown. Thus this method will never return null.

Specified by:
getControlSequence in interface TokenSource
Parameters:
context - the interpreter context
typesetter - the typesetter
Returns:
the token read
Throws:
HelpingException - in case that the token stream is at its end or that the token read is not a control sequence token
See Also:
TokenSource.getControlSequence( org.extex.interpreter.context.Context, org.extex.typesetter.Typesetter)

getFont

public Font getFont(Context context,
                    CodeToken primitive)
             throws HelpingException,
                    TypesetterException
Description copied from interface: TokenSource
Parse the specification of a font.

This method parses the following syntactic entity:

A Font

    ⟨font⟩
 

Specified by:
getFont in interface TokenSource
Parameters:
context - the interpreter context
primitive - the name of the primitive for error messages
Returns:
a font specification
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.getFont( org.extex.interpreter.context.Context, CodeToken)

getKeyword

public boolean getKeyword(Context context,
                          java.lang.String s)
                   throws HelpingException
Scan the expanded token stream for a sequence of letter tokens. If all tokens are found then they are removed from the input stream and true is returned. Otherwise all tokens are left in the input stream and false is returned.

Specified by:
getKeyword in interface TokenSource
Parameters:
context - the interpreter context
s - the tokens to scan
Returns:
true iff the tokens could have been successfully removed from the input stream
Throws:
HelpingException - in case that no number is found or the end of file has been reached before an integer could be acquired

getLastToken

public Token getLastToken()
Description copied from interface: TokenSource
Getter for the token just previously read from the token source. This is something like a look-back function.

Specified by:
getLastToken in interface TokenSource
Returns:
the last token or null if not available
See Also:
TokenSource.getLastToken()

getLocator

public Locator getLocator()
Description copied from interface: TokenSource
Getter for the locator. The locator provides a means to get the information where something is coming from. Usually it points to a line in a file.

Specified by:
getLocator in interface TokenSource
Returns:
the current locator
See Also:
TokenSource.getLocator()

getNonSpace

public Token getNonSpace(Context context)
                  throws HelpingException
Get the next token which has not the category code SPACE.

Specified by:
getNonSpace in interface TokenSource
Parameters:
context - the interpreter context
Returns:
the next non-space token or null at EOF
Throws:
HelpingException - in case of an error
See Also:
TokenSource.getNonSpace( org.extex.interpreter.context.Context)

getNumber

public long getNumber(Token token)
               throws HelpingException,
                      MissingNumberException
Scan a number with a given first token.

Parameters:
token - the first token to consider
Returns:
the value of the integer scanned
Throws:
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

getOptionalEquals

public void getOptionalEquals(Context context)
                       throws HelpingException
Skip spaces and if the next non-space character is an equal sign skip it as well and all spaces afterwards.

Specified by:
getOptionalEquals in interface TokenSource
Parameters:
context - the interpreter context
Throws:
HelpingException - in case of an error
See Also:
TokenSource.getOptionalEquals( org.extex.interpreter.context.Context)

getToken

public Token getToken(Context context)
               throws HelpingException
Get the next token from the input streams. 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.

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.

Specified by:
getToken in interface TokenSource
Parameters:
context - the interpreter context
Returns:
the next token or null
Throws:
HelpingException - in case of an error
See Also:
TokenSource.getToken( org.extex.interpreter.context.Context)

getTokens

public Tokens getTokens(Context context,
                        TokenSource source,
                        Typesetter typesetter)
                 throws HelpingException,
                        TypesetterException
Get the next tokens form the input streams between { 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:

A Replacement Text

     ⟨replacement text⟩
 

Specified by:
getTokens in interface TokenSource
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the next tokens or null
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.getTokens( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

getTokenStreamFactory

public TokenStreamFactory getTokenStreamFactory()
Getter for the token stream factory.

Specified by:
getTokenStreamFactory in interface TokenSource
Returns:
the token stream factory

parse

public java.lang.Object parse(java.lang.Class c,
                              Context context,
                              TokenSource source,
                              Typesetter typesetter)
                       throws HelpingException,
                              TypesetterException
Parse some data type.

Specified by:
parse in interface TokenSource
Parameters:
c - the class
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the object obtained or null if at end of file
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.parse(java.lang.Class, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

parseDimen

public Dimen parseDimen(Context context,
                        TokenSource source,
                        Typesetter typesetter)
                 throws HelpingException,
                        TypesetterException
Acquire a length value and return it in multiples of scaled points.

Specified by:
parseDimen in interface DimenParser
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the length value
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
DimenParser.parseDimen( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

parseGlue

public Glue parseGlue(Context context,
                      TokenSource source,
                      Typesetter typesetter)
               throws HelpingException,
                      TypesetterException
Parse a glue value and return the result. If no glue value can be obtained an exception is raised.

Specified by:
parseGlue in interface GlueParser
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the value
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
GlueParser.parseGlue( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

parseInteger

public long parseInteger(Context context,
                         TokenSource source,
                         Typesetter typesetter)
                  throws HelpingException,
                         TypesetterException
Parse an integer. This number can either be positive or negative.

Specified by:
parseInteger in interface CountParser
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the value
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
CountParser.parseInteger( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

parseNumber

public long parseNumber(Context context,
                        TokenSource source,
                        Typesetter typesetter)
                 throws HelpingException,
                        TypesetterException
Parse a non-negative number.

Specified by:
parseNumber in interface CountParser
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the value
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
CountParser.parseNumber( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

push

public void push(Token token)
          throws HelpingException
Push back a token onto the input stream for subsequent reading.

Specified by:
push in interface TokenSource
Parameters:
token - the token to push
Throws:
HelpingException - in case of an error
See Also:
TokenSource.push( org.extex.scanner.type.token.Token)

push

public void push(Token[] tokens)
          throws HelpingException
Push back a list of tokens onto the input stream for subsequent reading.

Specified by:
push in interface TokenSource
Parameters:
tokens - the tokens to push
Throws:
HelpingException - in case of an error
See Also:
TokenSource.push( org.extex.scanner.type.token.Token[])

push

public void push(Tokens tokens)
          throws HelpingException
Push back a list of tokens onto the input stream for subsequent reading. In case that the argument is null then it is silently ignored.

Specified by:
push in interface TokenSource
Parameters:
tokens - the tokens to push
Throws:
HelpingException - in case of an error
See Also:
TokenSource.push( org.extex.scanner.type.tokens.Tokens)

register

public Parser register(java.lang.Class c,
                       Parser p)
                throws HelpingException
Register a new parser for some data type.

Specified by:
register in interface TokenSource
Parameters:
c - the class
p - the parser for the class
Returns:
the old parser for this class or null if none has been registered
Throws:
HelpingException - in case of an error
See Also:
TokenSource.register(java.lang.Class, org.extex.interpreter.parser.Parser)

registerObserver

public void registerObserver(EofObserver observer)
Add an observer for the eof event. This observer is triggered by an end of file on the token stream. This means that all tokens have been processed and all stream are at their end.

Specified by:
registerObserver in interface EofObservable
Parameters:
observer - the observer to add

registerObserver

public void registerObserver(OpenFileObserver observer)
Register an open file observer for later use.

Specified by:
registerObserver in interface OpenFileObservable
Parameters:
observer - the observer to be registered
See Also:
OpenFileObservable.registerObserver( org.extex.scanner.stream.observer.file.OpenFileObserver)

registerObserver

public void registerObserver(OpenReaderObserver observer)
Register an open reader observer for later use.

Specified by:
registerObserver in interface OpenReaderObservable
Parameters:
observer - the observer to be registered
See Also:
OpenReaderObservable.registerObserver( org.extex.scanner.stream.observer.reader.OpenReaderObserver)

registerObserver

public void registerObserver(OpenStringObserver observer)
Register an open string observer for later use.

Specified by:
registerObserver in interface OpenStringObservable
Parameters:
observer - the observer to be registered
See Also:
OpenStringObservable.registerObserver( org.extex.scanner.stream.observer.string.OpenStringObserver)

registerObserver

public void registerObserver(PopObserver observer)
Add an observer for the pop event. This observer is triggered by a pop operation on the token stream. This means that a token has been extracted.

Specified by:
registerObserver in interface PopObservable
Parameters:
observer - the observer to add

registerObserver

public void registerObserver(PushObserver observer)
Add an observer for the push event. This observer is triggered by a push operation on the token stream. This means that a token has been placed on the current stream for subsequent reading.

Specified by:
registerObserver in interface PushObservable
Parameters:
observer - the observer to add

registerObserver

public void registerObserver(StreamCloseObserver observer)
Register an stream close observer for later use.

Specified by:
registerObserver in interface StreamCloseObservable
Parameters:
observer - the observer to be registered
See Also:
StreamCloseObservable.registerObserver( org.extex.interpreter.observer.streamClose.StreamCloseObserver)

scanCharacterCode

public UnicodeChar scanCharacterCode(Context context,
                                     Typesetter typesetter,
                                     CodeToken primitive)
                              throws HelpingException,
                                     TypesetterException
Scan the input stream for tokens making up a character code, this is a sequence of digits with category code OTHER. The number can be preceded by optional white space. Alternate representations for an character code exist.

This method parses the following syntactic entity:

A Character Code

    ⟨character code⟩
 

A character is a positive number.

Tokens are expanded while gathering the requested values.

Specified by:
scanCharacterCode in interface TokenSource
Parameters:
context - the interpreter context
typesetter - the typesetter
primitive - the name of the invoking primitive for error handling
Returns:
the value of the integer scanned
Throws:
HelpingException - in case of an error
especially
InvalidCharacterException in case that no number is found or if it is out of the allowed range
EofException in case that an end of file has been encountered before the character code was complete
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.scanCharacterCode( org.extex.interpreter.context.Context, org.extex.typesetter.Typesetter, CodeToken)

scanNonSpace

public Token scanNonSpace(Context context)
                   throws HelpingException,
                          TypesetterException
Scan the input for the next token which has not the category code SPACE.

Specified by:
scanNonSpace in interface TokenSource
Parameters:
context - the interpreter context
Returns:
the next non-space token or null at EOF
Throws:
HelpingException - in case of an error in scanToken()
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.scanNonSpace( org.extex.interpreter.context.Context)

scanRegisterName

public java.lang.String scanRegisterName(Context context,
                                         TokenSource source,
                                         Typesetter typesetter,
                                         CodeToken primitive)
                                  throws HelpingException,
                                         TypesetterException
Description copied from interface: TokenSource
Scan the input streams for an entity to denote a register name. Upon EOF null is returned.

A Register Name

A register name determines under which key a register can be addressed. In TeX this used to be a positive number only. This has been extended to allow also a token list in braces.

The alternative is controlled by the integer register \maxregister. The following interpretation of the value of this count is used:

  • If the value of this integer register is negative then a arbitrary non-negative number is allowed as register name as well as any list of tokens enclosed in braces.
  • If the value of this integer register is not-negative then a only a non-negative number is allowed as register name which does not exceed the value of the integer register.

The value of the integer register \maxRegister is set differently for various configurations of ExTeX:

  • TeX uses the value 255.
  • eTeX uses the value 32767.
  • Omega uses the value 65536.
  • ExTeX uses the value -1.

Te integer register \maxRegister is defined in the name space system. Thus special actions have to be used to access it.

Syntax

    ⟨register name⟩
        → ⟨tokens⟩
         | ⟨number⟩
 

Examples

   123
   {abc}
 

Specified by:
scanRegisterName in interface TokenSource
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
primitive - the name of the invoking primitive for error handling
Returns:
the register name encountered
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.scanRegisterName( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter, CodeToken)

scanToken

public Token scanToken(Context context)
                throws HelpingException,
                       TypesetterException
Get the next expanded token form the input streams. 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 null is returned.

Specified by:
scanToken in interface TokenSource
Parameters:
context - the interpreter context
Returns:
the next token or null
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.scanToken( org.extex.interpreter.context.Context)

scanTokens

public Tokens scanTokens(Context context,
                         boolean reportUndefined,
                         boolean ignoreUndefined,
                         CodeToken primitive)
                  throws HelpingException,
                         TypesetterException
Get the next expanded token form the input streams between { 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:

A General text

     ⟨general text⟩
 

Specified by:
scanTokens in interface TokenSource
Parameters:
context - the interpreter context
reportUndefined - indicator that an undefined control sequence leads to an exception. This parameter is effective only if ignoreUndefined is false
ignoreUndefined - indicator that an undefined control sequence should be treated as \relax
primitive - the name of the invoking primitive for error handling
Returns:
the next tokens read so far. The return value is guaranteed not to be null under any circumstances
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.scanTokens( org.extex.interpreter.context.Context, boolean, boolean, org.extex.scanner.type.token.CodeToken)

scanTokensAsString

public java.lang.String scanTokensAsString(Context context,
                                           CodeToken primitive)
                                    throws HelpingException,
                                           TypesetterException
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. If the end of file is reached then an Exception is raised.

Specified by:
scanTokensAsString in interface TokenSource
Parameters:
context - the interpreter context
primitive - the name of the invoking primitive for error handling
Returns:
the next tokens as String or null
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.scanTokensAsString( org.extex.interpreter.context.Context, CodeToken)

scanUnprotectedTokens

public Tokens scanUnprotectedTokens(Context context,
                                    boolean reportUndefined,
                                    boolean ignoreUndefined,
                                    CodeToken primitive)
                             throws HelpingException,
                                    TypesetterException
Get the next expanded tokens from the input streams between { 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.

Specified by:
scanUnprotectedTokens in interface TokenSource
Parameters:
context - the interpreter context
reportUndefined - indicator that an undefined control sequence leads to an exception. This parameter is effective only if ignoreUndefined is false
ignoreUndefined - indicator that an undefined control sequence should be treated as \relax
primitive - the name of the invoking primitive for error handling
Returns:
the next tokens or null
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokenSource.scanUnprotectedTokens( org.extex.interpreter.context.Context, boolean, boolean, CodeToken)

setTokenStreamFactory

public void setTokenStreamFactory(TokenStreamFactory factory)
Setter for the token stream factory.

Specified by:
setTokenStreamFactory in interface Interpreter
Parameters:
factory - the token stream factory
Throws:
ConfigurationException - this exception is never thrown. It is defined here to provide an exit for derived classes

skipSpace

public void skipSpace()
Skip spaces and check whether any tokens are left.

Specified by:
skipSpace in interface TokenSource
See Also:
TokenSource.skipSpace()

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

update

public void update(java.lang.String name,
                   java.lang.String text)
            throws NotObservableException
Send the string to the named observer. The observer must be capable to deal with a string argument.

Specified by:
update in interface TokenSource
Parameters:
name - name of the observer
text - the text to send to the observer
Throws:
NotObservableException - in case that the named observer is not accessible
See Also:
TokenSource.update(java.lang.String, java.lang.String)