Package jminusminus
Class LookaheadScanner
java.lang.Object
jminusminus.LookaheadScanner
A lexical analyzer for j-- that interfaces with the hand-written parser (Parser). It
 provides a backtracking mechanism, and makes use of the underlying hand-written scanner
 (Scanner).
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanReturns true if an error has occurred, and false otherwise.fileName()Returns the name of the source file.voidnext()Scans to the next token in the input.Returns the previous token.voidRecords the current position in the input, so that we can start looking ahead in the input (and later return to this position) --- the current and subsequent tokens are queued until returnToPosition() is invoked.voidReturns to the previously recorded position in the input stream of tokens.token()Returns the current token.
- 
Field Details- 
isLookingAheadpublic boolean isLookingAhead
 
- 
- 
Constructor Details- 
LookaheadScannerConstructs a LookaheadScanner.- Parameters:
- fileName- the name of the file containing the source.
- Throws:
- FileNotFoundException- when the named file cannot be found.
 
 
- 
- 
Method Details- 
nextpublic void next()Scans to the next token in the input.
- 
recordPositionpublic void recordPosition()Records the current position in the input, so that we can start looking ahead in the input (and later return to this position) --- the current and subsequent tokens are queued until returnToPosition() is invoked.
- 
returnToPositionpublic void returnToPosition()Returns to the previously recorded position in the input stream of tokens.
- 
tokenReturns the current token.- Returns:
- the current token.
 
- 
previousTokenReturns the previous token.- Returns:
- the previous token.
 
- 
errorHasOccuredpublic boolean errorHasOccured()Returns true if an error has occurred, and false otherwise.- Returns:
- true if an error has occurred, and false otherwise.
 
- 
fileNameReturns the name of the source file.- Returns:
- the name of the source file.
 
 
-