Package minitex

Class MiniTexParser

java.lang.Object
minitex.MiniTexParser

public class MiniTexParser extends Object
This class provides a reader for a style configuration file.

The parser reads form the input reader and extracts macros invocations and environments on the top level. The following restrictions apply:

  1. Macros must have a single argument. An exception is the macro \endinput which terminates the reading immediately.
  2. Environments may not have any argument. Arguments of environments are digested as part of their body.
  3. Comments are honored, i.e. discarded until end of line.

The arguments of macros and the body of environments are stored in map. The key is the name of the macro or environment. Macros and environments are treated identically. Thus the following instructions are the same:

 \abc{123}
 
and
 \begin{abc}123\end{abc}
 

Macros and environments may contain code. This is not interpreted. It is taken literally as the value. Nevertheless the blocks and environments need to be balanced.

The same macro and environment name can be used several timed. The values for the same key are stored in a list. The order of the elements in this list is the order in the input.

  • Constructor Details

    • MiniTexParser

      public MiniTexParser(Reader reader)
      This is the constructor for MiniTeXParser.
      Parameters:
      reader - the reader
  • Method Details

    • add

      public void add(String key, String value)
      This method add a value to the definitions map.
      Parameters:
      key - the key
      value - the value
    • parse

      public Map<String,List<String>> parse() throws IOException
      This method reads the input and stores the top-level macros and environments in a map.
      Returns:
      the macros and environments found
      Throws:
      IOException - in case of an error