类 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.
-
-
构造器概要
构造器 构造器 说明 ParserContext(java.lang.String input)Initialize a new parser context from the given input string.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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.
-
-
-
方法详细资料
-
snapshot
public void snapshot()
-
commit
public void commit()
Drop the last snapshot, use the currently valid parser state.
-
revert
public void revert()
Reverts to the last valid snapshot.
-
peekChar
public char peekChar(int offset) throws java.io.EOFExceptionLook-ahead at the input string.- 参数:
offset- The number of characters that should be skipped. E.g. 0 means look at the currently parsed character.- 返回:
- The character at the proper offset in the input.
- 抛出:
java.io.EOFException- When the read attempts to read anything past the end of the input string.
-
peekCharUnchecked
public 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.- 参数:
offset- The offset of the character to look at.- 返回:
- The character at the given position.
-
advance
public void advance(int amount)
Consume the given number of characters.- 参数:
amount- The number of characters to consider parsed.
-
remainingLength
public int remainingLength()
- 返回:
- The remaining length of the input string.
-
chopFront
public java.lang.String chopFront(int length)
Consume length characters from the input string, return them in a newly constructed string.- 参数:
length- The number of characters to consume from the beginning. (The method just callsadvance(int)internally with this number.)- 返回:
- A string of length length that appears at the current position in the input.
-
startsWith
public boolean startsWith(java.lang.String prefix)
Tests whether the current state starts with the given string.- 参数:
prefix- The prefix we are checking for.- 返回:
- True if the current input at the current offset starts with the given string.
-
indexOf
public int indexOf(char c)
Returns first index of a given character in the remaining part of the input string.- 参数:
c- The character to search for.- 返回:
- The offset of the character from the current position, or -1 if not found.
-
-