Class IncludingCharBuf<D>

java.lang.Object
eu.bandm.tools.rdparser.IncludingCharBuf<D>
Type Parameters:
D - is the document type identifier for the locations.

public class IncludingCharBuf<D> extends Object
Auxiliary class for TunableParser, which expands entities by inserting their expansion text directly into the delivered character stream.
  • Field Details

    • top

      Currently read character source.
    • eotextLocation

      @Opt protected @Opt Location<D> eotextLocation
      The location after consuming the last character is stored here to be still deliverable when the finished buffer has been discarded.
    • initialFirstColumnNumber

      protected int initialFirstColumnNumber
      Memorize the column number of the location on construction. If no such is given, it defaults to 0.
    • CHAR_EOTEXT

      public static final char CHAR_EOTEXT
      Reserved character (0x0000) which is only delivered when reading past the end of the input.
      See Also:
  • Constructor Details

    • IncludingCharBuf

      public IncludingCharBuf(Reader r, @Opt @Opt Location<D> loc) throws IOException
      Initialize with the complete char stream readable from r.
      Parameters:
      r - character data to start with.
      loc - location associated with the BEGIN of the data, for subsequent error messages.
      Throws:
      IOException
    • IncludingCharBuf

      @Deprecated(since="0.0") public IncludingCharBuf(String s)
      Deprecated.
      use the variant with a location information.
    • IncludingCharBuf

      public IncludingCharBuf(String s, @Opt @Opt Location<D> loc)
      Initialize with the complete content of s.
      Parameters:
      s - character data to start with.
      loc - location associated with the BEGIN of the data, for subsequent error messages.
  • Method Details

    • include

      public void include(String s, Location<D> loc)
      Insert the complete content of s at the current position. After this is consumed, resume the deliverance of the current source.
      Parameters:
      s - character data to insert.
      loc - location associated with the BEGIN of the insertion, for subsequent error messages.
    • include

      public void include(char[] s, @Opt @Opt Location<D> loc)
      Insert the complete content of s at the current position. After this is consumed, resume the deliverance of the current source.
      Parameters:
      s - character data to insert.
      loc - location associated with the BEGIN of the insertion, for subsequent error messages.
    • LA

      public char LA(int k)
      Deliver the k-th look-ahead character. The next-to-consume character is looked at with k=1(one)! (This differs from the definitions in IncludingCharBuf<D>.CharBuf!!)
    • getCurrentLocation

      public Location<D> getCurrentLocation()
      Deliver the position of the last executed consume().
    • getLocationChain

      public List<Location<D>> getLocationChain()
      Returns the list of the locations: the current parser position, and the parser positions where the insertion was started, ie where the expanded macro has been called.
    • getCallingLocationString

      public String getCallingLocationString()
      Returns the list of the locations in a human-readable string notation. First the current parser position, and the parser positions where the insertion was started, ie where the expanded macro has been called.
    • consume

      public void consume()
      Swallow the next character, advance the location by one position, and reconstruct the inserting source, in case the inserted source has reached its end.

      Contract: only called if the next character is an expected one.

      This char may be "end of input" CHAR_EOTEXT. In this case a further (erroneous!) LA() call would find a further CHAR_EOTEXT, infinitely often.