Class IncludingCharBuf<D>

java.lang.Object
eu.bandm.tools.util2.IncludingCharBuf<D>

public class IncludingCharBuf<D> extends Object
Auxiliary class for TunableParser, which expands entities by inserting their expansion text directly into the delivered character stream.
The parameter <D> is the document type identifier for the locations.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
    Auxiliary class for IncludingCharBuf, representing exactly one source of character data, ie the original file or inserted expansions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    Reserved character (0x0000) which is only delivered when reading past the end of the input.
    protected Location<D>
    The location after consuming the last character is stored here to be still deliverable when the finished buffer has been discarded.
    (package private) IncludingCharBuf<D>.CharBuf
    Currently read character source.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initialize with the complete char stream readable from r.
    Deprecated.
    Initialize with the complete content of s.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Swallow the next character, advance the location by one position, and reconstruct the inserting source, in case the inserted source has reached its end.
    Returns the list of the locations in a human-readable string notation.
    Deliver the position of the last executed consume().
    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.
    void
    include(char[] s, Location<D> loc)
    Insert the complete content of s at the current position.
    void
    Insert the complete content of s at the current position.
    char
    LA(int k)
    Deliver the k-th look-ahead character.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • top

      Currently read character source.
    • eotext_location

      protected Location<D> eotext_location
      The location after consuming the last character is stored here to be still deliverable when the finished buffer has been discarded.
    • 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, 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 public IncludingCharBuf(String s)
      Deprecated.
    • IncludingCharBuf

      public IncludingCharBuf(String s, 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, 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.