- java.lang.Object
-
- com.ibm.dtfj.javacore.parser.framework.scanner.LookAheadBuffer
-
- All Implemented Interfaces:
ILookAheadBuffer
public class LookAheadBuffer extends Object implements ILookAheadBuffer
-
-
Constructor Summary
Constructors Constructor Description LookAheadBuffer(int size, IScanner scanner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
consume()
Consumes the first element in the buffervoid
init()
IParserToken
lookAhead(int depth)
Looks ahead by a depth amount.boolean
match(String tokenType)
Matches a given type to the token type found at the first element of the buffer.void
setLookAheadDepth(int depth)
Depth of the lookahead can be changed after creation.-
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods declared in interface com.ibm.dtfj.javacore.parser.framework.parser.ILookAheadBuffer
allConsumed, length, maxDepth
-
-
-
-
Constructor Detail
-
LookAheadBuffer
public LookAheadBuffer(int size, IScanner scanner)
-
-
Method Detail
-
match
public boolean match(String tokenType)
Description copied from interface:ILookAheadBuffer
Matches a given type to the token type found at the first element of the buffer.- Specified by:
match
in interfaceILookAheadBuffer
- Parameters:
tokenType
-- Returns:
- true if match is successful
-
consume
public void consume() throws IOException, ScannerException
Consumes the first element in the buffer- Specified by:
consume
in interfaceILookAheadBuffer
- Throws:
ScannerException
IOException
-
lookAhead
public IParserToken lookAhead(int depth) throws IOException, ScannerException, IndexOutOfBoundsException
Description copied from interface:ILookAheadBuffer
Looks 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:
lookAhead
in interfaceILookAheadBuffer
- Parameters:
depth
- to lookahead- Returns:
- token at specified lookahead depth or
IndexOutOfBoundsException
. - Throws:
ScannerException
IOException
IndexOutOfBoundsException
- if depth is outside the depth range of the buffer. Minimum depth is always 1.- See Also:
ILookAheadBuffer.lookAhead(int)
-
init
public void init() throws IOException, ScannerException
- Specified by:
init
in interfaceILookAheadBuffer
- Throws:
ScannerException
IOException
-
setLookAheadDepth
public void setLookAheadDepth(int depth) throws IOException, ScannerException
Description copied from interface:ILookAheadBuffer
Depth 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:
setLookAheadDepth
in interfaceILookAheadBuffer
- Parameters:
depth
- to change- Throws:
ScannerException
IOException
- See Also:
ILookAheadBuffer.setLookAheadDepth(int)
-
-