Package cs1302.tracer.trace
Class InputTracker
java.lang.Object
cs1302.tracer.trace.InputTracker
Tracks the progressive, monotonic consumption of standard input during guest program execution.
-
Constructor Summary
ConstructorsConstructorDescriptionInputTracker(String stdin) Constructs a newInputTrackerwith the specified standard input string. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsumeBytes(int count) Records raw UTF-8 byte consumption, advancing only through complete code points.consumed()Returns the cumulative string of standard input consumed up to this point.voidconsumeLine(String line) Records consumption of a full line (e.g., fromScanner.nextLine,BufferedReader.readLine, orIO.readln), advancing through the line and consuming any immediate line terminator (CRLF, LF, or CR).voidconsumeToken(String token) Records consumption of a token (e.g., fromScanner.next*), advancing past any leading whitespace/delimiters and through the token itself.booleanReturns true if all standard input has been consumed.intoffset()Returns the current character offset within the standard input.stdin()Returns the complete standard input string.Returns the unconsumed portion of standard input.
-
Constructor Details
-
InputTracker
Constructs a newInputTrackerwith the specified standard input string.- Parameters:
stdin- The standard input string provided to the guest.
-
-
Method Details
-
stdin
Returns the complete standard input string.- Returns:
- The standard input string.
-
consumed
Returns the cumulative string of standard input consumed up to this point.- Returns:
- Substring of consumed standard input.
-
offset
public int offset()Returns the current character offset within the standard input.- Returns:
- Current 0-based character index.
-
unconsumed
Returns the unconsumed portion of standard input.- Returns:
- Unconsumed standard input substring.
-
isExhausted
public boolean isExhausted()Returns true if all standard input has been consumed.- Returns:
- True if cursor reached or exceeded standard input length.
-
consumeToken
Records consumption of a token (e.g., fromScanner.next*), advancing past any leading whitespace/delimiters and through the token itself.- Parameters:
token- The token consumed.
-
consumeLine
Records consumption of a full line (e.g., fromScanner.nextLine,BufferedReader.readLine, orIO.readln), advancing through the line and consuming any immediate line terminator (CRLF, LF, or CR).- Parameters:
line- The line content consumed (excluding newline delimiter).
-
consumeBytes
public void consumeBytes(int count) Records raw UTF-8 byte consumption, advancing only through complete code points. Character offsets remain UTF-16 indices into the supplied input string.- Parameters:
count- Number of bytes consumed byInputStream.read.
-