ModuleAgda-2.8.0.2Haskell2010
Agda.Syntax.Parser.LookAhead
When lexing by hand (for instance string literals) we need to do some looking ahead. The LookAhead monad keeps track of the position we are currently looking at, and provides facilities to synchronise the look-ahead position with the actual position of the Parser monad (see sync and rollback).
Contents
Synopsis
- newtype LookAhead
- value runLookAhead
- value lookAheadError
- value getInput
- value setInput
- value liftP
- value nextChar
- value eatNextChar
- value sync
- value rollback
- value match
- value match'
- PackageAgda-2.8.0.2
- Exports12
- LanguageHaskell2010
- LicenceMIT
- SourceLookAhead.hs
The LookAhead monad
Run a LookAhead computation. The first argument is the error function.
Operations
Throw an error message according to the supplied method.
Get the current look-ahead position.
Set the look-ahead position.
Look at the next character. Fails if there are no more characters.
Consume all the characters up to the current look-ahead position.
Undo look-ahead. Restores the input from the ParseState.
Do a case on the current input string. If any of the given strings match we move past it and execute the corresponding action. If no string matches, we execute a default action, advancing the input one character. This function only affects the look-ahead position.
Same as match but takes the initial character from the first argument instead of reading it from the input. Consequently, in the default case the input is not advanced.