java.lang.Object
com.ibm.dtfj.javacore.parser.framework.scanner.LookAheadBuffer
- All Implemented Interfaces:
ILookAheadBuffer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidconsume()Consumes the first element in the buffervoidinit()intlength()lookAhead(int depth) Looks ahead by a depth amount.booleanMatches a given type to the token type found at the first element of the buffer.intmaxDepth()voidsetLookAheadDepth(int depth) Depth of the lookahead can be changed after creation.
-
Constructor Details
-
LookAheadBuffer
-
-
Method Details
-
match
Description copied from interface:ILookAheadBufferMatches a given type to the token type found at the first element of the buffer.- Specified by:
matchin interfaceILookAheadBuffer- Parameters:
tokenType-- Returns:
- true if match is successful
-
consume
Consumes the first element in the buffer- Specified by:
consumein interfaceILookAheadBuffer- Throws:
ScannerExceptionIOException
-
allConsumed
public boolean allConsumed()- Specified by:
allConsumedin interfaceILookAheadBuffer- Returns:
- true if all tokens from both the input stream and the lookahead buffer have been consumed
-
lookAhead
public IParserToken lookAhead(int depth) throws IOException, ScannerException, IndexOutOfBoundsException Description copied from interface:ILookAheadBufferLooks ahead by a depth amount. The lowest depth to look ahead is 1. Note that in some cases, a lookahead may be attempted on an earlier error condition that lead to an empty buffer (e.g., an exception was thrown during a fill process, and although more tokens may remain in the input source, the lookahead value may itself be null. Consequently, the lookahead buffer refills first before attempting the lookahead.- Specified by:
lookAheadin interfaceILookAheadBuffer- Parameters:
depth- to lookahead- Returns:
- token at specified lookahead depth or
IndexOutOfBoundsException. - Throws:
ScannerExceptionIOExceptionIndexOutOfBoundsException- if depth is outside the depth range of the buffer. Minimum depth is always 1.- See Also:
-
init
- Specified by:
initin interfaceILookAheadBuffer- Throws:
ScannerExceptionIOException
-
setLookAheadDepth
Description copied from interface:ILookAheadBufferDepth of the lookahead can be changed after creation.
If the new depth is less that the current depth, no new tokens will be read until the outstanding tokens (current depth - new depth) are first consumed.
If the new depth is greater than the current depth, the lookahead will read new tokens to fill the delta.- Specified by:
setLookAheadDepthin interfaceILookAheadBuffer- Parameters:
depth- to change- Throws:
ScannerExceptionIOException- See Also:
-
length
public int length()- Specified by:
lengthin interfaceILookAheadBuffer
-
maxDepth
public int maxDepth()- Specified by:
maxDepthin interfaceILookAheadBuffer
-