|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TokenSource
This interface describes a class to acquire
Token
s from. Beside the pure
getter for the next token some higher-level parsing methods are provided here
as well.
There are two classes of methods for reading something from a token stream. The methods starting with get perform the raw reading, whereas the methods starting with scan perform expansion as well.
Method Summary | |
---|---|
void |
addStream(TokenStream stream)
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. |
void |
execute(Token token,
Context context,
Typesetter typesetter)
Tries to execute a token. |
void |
executeGroup()
Scan and execute tokens until the group ends. |
Token |
expand(Token token,
Context context,
Typesetter typesetter)
Try to expand a single token and return the result. |
Tokens |
expand(Tokens tokens,
Typesetter typesetter)
Expand some tokens. |
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 keyword)
Get tokens from the token stream searching 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 . |
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 form 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. |
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. |
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 |
skipSpace()
Skip spaces and check whether any tokens are left. |
void |
update(java.lang.String name,
java.lang.String text)
Send the string to the named observer. |
Methods inherited from interface org.extex.interpreter.parser.CountParser |
---|
parseInteger, parseNumber |
Methods inherited from interface org.extex.interpreter.parser.DimenParser |
---|
parseDimen |
Methods inherited from interface org.extex.interpreter.parser.GlueParser |
---|
parseGlue |
Method Detail |
---|
void addStream(TokenStream stream)
stream
- the new stream to read fromvoid closeAllStreams(Context context) throws HelpingException
context
- the interpreter context
HelpingException
- in case of an errorvoid closeNextFileStream(Context context) throws HelpingException
context
- the interpreter context
HelpingException
- in case of an errorvoid execute(Token token, Context context, Typesetter typesetter) throws HelpingException
token
- the Token to executecontext
- the interpreter contexttypesetter
- the typesetter
HelpingException
- in case of an errorvoid executeGroup() throws HelpingException
HelpingException
- in case of an errorToken expand(Token token, Context context, Typesetter typesetter) throws HelpingException, ConfigurationException, TypesetterException
token
- the token to expandcontext
- the interpreter contexttypesetter
- the typesetter
HelpingException
- in case of an error
TypesetterException
- in case of a typesetter error
ConfigurationException
- in case of a configuration errorTokens expand(Tokens tokens, Typesetter typesetter) throws GeneralException, ConfigurationException
tokens
- the tokens to expandtypesetter
- the typesetter to use
GeneralException
- in case of an error
ConfigurationException
- in case of an configuration problemBox getBox(Flags flags, Context context, Typesetter typesetter, Token insert) throws HelpingException, ConfigurationException, TypesetterException
This method parses the following syntactic entity:
〈box〉
flags
- 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 typesetterCodeToken getControlSequence(Context context, Typesetter typesetter) throws HelpingException
null
.
This method parses the following syntactic entity:
A control sequence is either a active character or an escape sequence. Macros can be assigned to control sequences only.
The definition of a control sequence highly depends on the current configuration of the parser as stored in the category codes. An active character is one with category code 13. A escape sequence starts with a character with category code 0 followed by an arbitrary number of letters – category code 11 – or a single character with any other category code.
〈control sequence〉 → <i>?<sub>13</sub></i> | <i>?<sub>0</sub></i><i>?</i> | <i>?<sub>0</sub></i><i>?<sub>11</sub></i>*
˜
\abc
context
- 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 tokenFont getFont(Context context, CodeToken primitive) throws HelpingException, TypesetterException
This method parses the following syntactic entity:
〈font〉
context
- 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 typesetterboolean getKeyword(Context context, java.lang.String keyword) throws HelpingException
true
is returned. Otherwise all tokens are left
in the input stream and false
is returned.
Spaces before the keyword are removed from the input stream. Those spaces are not restored, even if the keyword is not found.
Space tokens after the keyword are removed from the input stream.
context
- the interpreter contextkeyword
- the tokens to scan
true
iff the tokens could have been successfully
removed from the input stream
HelpingException
- in case of an errorToken getLastToken()
null
if not availableLocator getLocator()
Token getNonSpace(Context context) throws HelpingException
SPACE
.
context
- the interpreter context
null
at EOF
HelpingException
- in case of an errorvoid getOptionalEquals(Context context) throws HelpingException
This method parses the following syntactic entity:
The syntactic entity 〈equals〉 skips initial spaces and an equals sign of category 12 if one is found. In the latter case the following spaces are skipped as well.
〈equals〉 → 〈optional spaces〉 | 〈optional spaces〉 = <sub>12</sub> 〈optional spaces〉
context
- the interpreter context
HelpingException
- in case of an errorToken getToken(Context context) throws HelpingException
null
is
returned.
This method corresponds to the following syntax specification:
〈token〉
A single token depends on the category code of the characters.
context
- the interpreter context
null
HelpingException
- in case of an errorTokens 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〉
context
- 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 typesetterTokenStreamFactory getTokenStreamFactory()
java.lang.Object parse(java.lang.Class c, Context context, TokenSource source, Typesetter typesetter) throws HelpingException, TypesetterException
c
- 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 typesettervoid push(Token token) throws HelpingException
token
- the token to push
HelpingException
- in case of an errorvoid push(Token[] tokens) throws HelpingException
tokens
- the tokens to push
HelpingException
- in case of an errorvoid push(Tokens tokens) throws HelpingException
null
then it is silently
ignored.
tokens
- the tokens to push
HelpingException
- in case of an errorParser register(java.lang.Class c, Parser p) throws HelpingException
c
- the classp
- the parser for the class
null
if none has
been registered
HelpingException
- in case of an errorUnicodeChar 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.
context
- 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 typesetterToken scanNonSpace(Context context) throws HelpingException, TypesetterException
context
- the interpreter context
null
at EOF
HelpingException
- in case of an error in
scanToken()
TypesetterException
- in case of an error in the typesetterjava.lang.String scanRegisterName(Context context, TokenSource source, Typesetter typesetter, CodeToken primitive) throws HelpingException, TypesetterException
null
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}
context
- 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 typesetterToken scanToken(Context context) throws HelpingException, TypesetterException
null
is returned.
context
- the interpreter context
null
HelpingException
- in case of an error
TypesetterException
- in case of an error in the typesetterTokens 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〉
context
- the interpreter contextprimitive
- the name of the invoking primitive for error handlingreportUndefined
- 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
null
under any circumstances
HelpingException
- in case of an error
TypesetterException
- in case of an error in the typesetterjava.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.
context
- 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 typesetterTokens 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.
context
- the interpreter contextprimitive
- the name of the invoking primitive for error handlingreportUndefined
- 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
null
HelpingException
- in case of an error
TypesetterException
- in case of an error in the typesettervoid skipSpace()
This method corresponds to the following specification:
This syntactic entity corresponds to an arbitrary number of white-space characters. White-space characters include space, ta and newline characters.
〈optional spaces〉 → [ \t\n]*
void update(java.lang.String name, java.lang.String text) throws HelpingException, NotObservableException
name
- name of the observertext
- the text to send to the observer
HelpingException
- in case of an error
NotObservableException
- in case that the named observer is not
accessible
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |