Agda-2.6.0: A dependently typed functional programming language and proof assistant

Contents

Description

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).

Synopsis

The LookAhead monad is basically a state monad keeping with an extra AlexInput, wrapped around the Parser monad.

Instances

Run a LookAhead computation. The first argument is the error function.

# Operations

Throw an error message according to the supplied method.

liftP :: Parser a -> LookAhead a Source #

Lift a computation in the Parser monad to the LookAhead monad.

Look at the next character. Fails if there are no more characters.

Consume the next character. Does nextChar followed by sync.

Consume all the characters up to the current look-ahead position.

Undo look-ahead. Restores the input from the ParseState.

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.