Tokens.
This is probably the most complex class in SnuggleTeX!
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv static class | LaTeXTokeniser.
Trivial "struct" Object to hold the results of searching for command and/or environment arguments. |
| public static class | LaTeXTokeniser.
Trivial "struct" encapsulating information about the state of a tokenisation mode. |
| public static class | LaTeXTokeniser.
This implementation of |
| public static class | LaTeXTokeniser.
This implementation of |
| public static interface | LaTeXTokeniser.
Represents the "terminator" characters that signify the end of a parsing mode. |
| public static enum | LaTeXTokeniser.
Enumeration of the various "tokenisation modes" we will be running in. This is only really used for documentation during debugging! |
| pack-priv static class | LaTeXTokeniser.
Trivial "struct" Object to hold the results of searching for user-defined
command and/or environment arguments, which are initially treated as unparsed
but balanced |
| Modifier and Type | Field and Description |
|---|---|
| private LaTeXTokeniser. | currentModeState
Current parsing "mode" |
| private final ArrayListStack | modeStack
Stack of parsing modes, with the last entry being equal to |
| private final NumberMatcher | numberMatcher
|
| private final ArrayListStack | openEnvironmentStack
Stack of open environments |
| private int | position
Current position within |
| public static final Set | reservedCommands
Set of reserved commands. |
| private final SessionContext | sessionContext
Provides access to the current |
| private int | startTokenIndex
Index of the start of the current token being parsed. |
| private static final String | UDE_POST_BEGIN
Name of internal command that gets temporarily appended after the begin clauses of a
user-defined environment has been substituted in order to make sure the
|
| private WorkingDocument | workingDocument
Current "working document", taking into account command/environment substitutions. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private String | advanceOverBracesAndEnvironmentName()
Reads text of the form '{envName}' from the current position onwards, skipping any leading comments/whitespace and advancing the current position to just after the final '}'. |
| private ErrorToken | Returns: ErrorToken if parsing failed, null otherwise.blank result Object that will be filled in by this method. resultThis helper reads in the optional and required arguments for a Command or Environment, starting at the current position. |
| private ErrorToken | advanceOverUserDefinedCommandOrEnvironmentArgumentDefinition(final String commandOrEnvironmentName, final LaTeXTokeniser.
Reads in the argument specification for a new command or environment. |
| private ErrorToken | Returns: ErrorToken if parsing failed, null otherwise.blank result Object that will be filled in by this method. resultThis helper reads in the optional and required arguments for a Command or Environment, starting at the current position. |
| private ErrorToken | checkDefinitionArguments(final FrozenSlice definitionSlice, final String commandOrEnvironmentName, final LaTeXTokeniser.
This helper checks the definition of a user-defined command or environment to make sure that any argument references are in line with what is defined. |
| private ErrorToken | createError(final ErrorCode errorCode, final int errorStartIndex, final int errorEndIndex, final Object... arguments)
|
| private int | findEndCurlyBrackets(final int openBraceIndex)
Returns the index of the next balanced '}', or -1 if no balance was found. |
| private int | findEndSquareBrackets(final int openSquareBracketIndex)
Returns the index of the next ']', handling any balanced braces appropriately. |
| private FlowToken | finishBeginBuiltinEnvironment(final BuiltinEnvironment
environment being read in environment)Finishes off reading a built-in environment. |
| private FlowToken | |
| private FlowToken | finishBeginUserDefinedEnvironment(final UserDefinedEnvironment environment)
Finishes the handling of the start of a user-defined environment. |
| private FlowToken | finishBuiltinCommand(final BuiltinCommand command)
Finishes reading in a |
| private FlowToken | finishCombiningCommand(final BuiltinCommand command)
Deals with pulling in the next token after something like \not PRE-CONDITION: position will point to the character immediately after \commandName. |
| private FlowToken | finishCommand(final String
name of the command being read in commandName)Finishes reading a Command, which will either be a |
| private FlowToken | finishCommandDefinition(final BuiltinCommand definitionCommand)
Finishes reading the definition of a user-defined command specified using \\newcommand or similar. |
| private FlowToken | finishComplexCommand(final BuiltinCommand command)
Finishes the process or reading in a "complex" command, by searching for any required and optional arguments. |
| private FlowToken | |
| private FlowToken | finishEndUserDefinedEnvironment(final UserDefinedEnvironment environment)
Finishes the handling of the end of a user-defined environment. |
| private FlowToken | finishEnvironmentDefinition(final BuiltinCommand definitionCommand)
Finishes reading the definition of a user-defined environment specified using \\newenvironment or similar. |
| private FlowToken | |
| private FlowToken | finishUserDefinedCommand(final UserDefinedCommand command)
Finishes the process of reading in and evaluating a |
| private FlowToken | finishVerbToken(BuiltinCommand verbCommand)
This is called once it has become clear that the next token is \verb or \verb*. |
| private FlowToken | handleUserDefinedEnvironmentControl()
Handles the special internal "begin user-defined environment finished" token that is substituted into the input when processing the start of a user-defined environment. |
| private ErrorToken | makeSubstitutionAndRewind(final int startIndex, final int endIndex, final CharSequence replacement)
Makes a substitution within the working document, replacing the position of the
|
| private BraceContainerToken | |
| private String | Returns: command name String, which will contain at least one character, or null if there were no further characters in the Slice.index to start reading from. startCommandNameIndex)Helper to read in the command or environment name starting at the given index, obeying the esoteric rules of naming. |
| private FlowToken | |
| private FlowToken | |
| private FlowToken | |
| private SimpleToken | readNextSimpleTextParaMode()
Reads either the next text lump or "new paragraph" tokens, until the start of something else. |
| private FlowToken | Returns: next token read in, or null if the input ended or we hit the terminator for the currentModeState. (You can test whether we hit a terminator by checking
ModeState#foundTerminator.)Reads the next token before the current terminator, returning null on end of input or if the terminator is discovered. |
| private FlowToken | |
| private FlowToken | |
| private FlowToken | readNextTokenVerbatimMode()
This reads the next token in |
| private FlowToken | |
| public void | |
| private void | |
| private void | skipOverComments()
Advances the current position past any comments and/or whitespace, including newlines. |
| private void | skipOverCommentsAndWhitespace()
Advances the current position past any comments and/or whitespace, including newlines. |
| private void | |
| private String | substituteArguments(final FrozenSlice slice, final UserDefinedCommandOrEnvironment commandOrEnvironment, final LaTeXTokeniser.
This helper substitutes the arguments provided for a user-defined command/environment
into the content of the given |
| public RootToken | tokenise(final SnuggleInputReader reader)
Tokenises the input specified by the given |
| private LaTeXTokeniser. | tokeniseInNewState(final LaTeXTokeniser.
Tokenises the |
| private SimpleToken | Returns: SimpleToken representing the number, or null if input wasn't a number.Attempts to read in a (positive) number at the current position, returning null if the input doesn't look like a number. |