Package eu.bandm.tools.util2
Class IncludingCharBuf<D>
java.lang.Object
eu.bandm.tools.util2.IncludingCharBuf<D>
Auxiliary class for
The parameter <D> is the document type identifier for the locations.
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
Modifier and TypeClassDescriptionprotected class
Auxiliary class forIncludingCharBuf
, representing exactly one source of character data, ie the original file or inserted expansions. -
Field Summary
Modifier and TypeFieldDescriptionstatic final char
Reserved character (0x0000) which is only delivered when reading past the end of the input.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
ConstructorDescriptionIncludingCharBuf
(Reader r, Location<D> loc) Initialize with the complete char stream readable from r.Deprecated.IncludingCharBuf
(String s, Location<D> loc) Initialize with the complete content of s. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Returns the list of the locations in a human-readable string notation.Deliver the position of the last executedconsume()
.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
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.
-
Field Details
-
top
IncludingCharBuf<D>.CharBuf topCurrently read character source. -
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_EOTEXTReserved character (0x0000) which is only delivered when reading past the end of the input.- See Also:
-
-
Constructor Details
-
IncludingCharBuf
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. -
IncludingCharBuf
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
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
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 inIncludingCharBuf<D>.CharBuf
!!) -
getCurrentLocation
Deliver the position of the last executedconsume()
. -
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
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 furtherCHAR_EOTEXT
, infinitely often.
-