Class ParserContext
- java.lang.Object
- 
- proguard.classfile.attribute.signature.parsing.ParserContext
 
- 
 public final class ParserContext extends java.lang.ObjectAn object for storing the data of a currently running parsing operation. Wraps the input string and also stores the current offset that is being parsed.
- 
- 
Constructor SummaryConstructors Constructor Description ParserContext(java.lang.String input)Initialize a new parser context from the given input string.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvance(int amount)Consume the given number of characters.java.lang.StringchopFront(int length)Consume length characters from the input string, return them in a newly constructed string.voidcommit()Drop the last snapshot, use the currently valid parser state.intindexOf(char c)Returns first index of a given character in the remaining part of the input string.charpeekChar(int offset)Look-ahead at the input string.charpeekCharUnchecked(int offset)Same aspeekChar(int), but doesn't check for the end of the string.intremainingLength()voidrevert()Reverts to the last valid snapshot.voidsnapshot()Take a snapshot of the current state of the parser.booleanstartsWith(java.lang.String prefix)Tests whether the current state starts with the given string.
 
- 
- 
- 
Method Detail- 
snapshotpublic void snapshot() 
 - 
commitpublic void commit() Drop the last snapshot, use the currently valid parser state.
 - 
revertpublic void revert() Reverts to the last valid snapshot.
 - 
peekCharpublic char peekChar(int offset) throws java.io.EOFExceptionLook-ahead at the input string.- Parameters:
- offset- The number of characters that should be skipped. E.g. 0 means look at the currently parsed character.
- Returns:
- The character at the proper offset in the input.
- Throws:
- java.io.EOFException- When the read attempts to read anything past the end of the input string.
 
 - 
peekCharUncheckedpublic char peekCharUnchecked(int offset) Same aspeekChar(int), but doesn't check for the end of the string. Useful in loops bounded byremainingLength()to avoid the need for a try-catch block.- Parameters:
- offset- The offset of the character to look at.
- Returns:
- The character at the given position.
 
 - 
advancepublic void advance(int amount) Consume the given number of characters.- Parameters:
- amount- The number of characters to consider parsed.
 
 - 
remainingLengthpublic int remainingLength() - Returns:
- The remaining length of the input string.
 
 - 
chopFrontpublic java.lang.String chopFront(int length) Consume length characters from the input string, return them in a newly constructed string.- Parameters:
- length- The number of characters to consume from the beginning. (The method just calls- advance(int)internally with this number.)
- Returns:
- A string of length length that appears at the current position in the input.
 
 - 
startsWithpublic boolean startsWith(java.lang.String prefix) Tests whether the current state starts with the given string.- Parameters:
- prefix- The prefix we are checking for.
- Returns:
- True if the current input at the current offset starts with the given string.
 
 - 
indexOfpublic int indexOf(char c) Returns first index of a given character in the remaining part of the input string.- Parameters:
- c- The character to search for.
- Returns:
- The offset of the character from the current position, or -1 if not found.
 
 
- 
 
-