HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleAgda-2.7.0.1Haskell2010

Agda.Syntax.Parser.Monad

  • 11 types
  • 27 values
  • PackageAgda-2.7.0.1
  • Exports38
  • LanguageHaskell2010
  • LicenceMIT
  • SourceMonad.hs

The parser monad

11 declarations
datadata ParseState
#

The parser state. Contains everything the parser and the lexer could ever need.

Constructors

Instances3Show, MonadState
datadata ParseError
#

Parse errors: what you get if parsing fails.

Constructors

Instances5Show, Pretty, HasRange, MonadError
datadata ParseWarning
#

Warnings for parsing.

Constructors

Instances6Show, NFData, Pretty, HasRange, EmbPrj, MonadState
typetype LexState = Int
#

For context sensitive lexing alex provides what is called start codes in the Alex documentation. It is really an integer representing the state of the lexer, so we call it LexState instead.

typetype LayoutContext = [LayoutBlock]
#

The stack of layout blocks.

When we encounter a layout keyword, we push a Tentative block with noColumn. This is replaced by aproper column once we reach the next token.

datadata LayoutStatus
#

Status of a layout column (see #1145). A layout column is Tentative until we encounter a new line. This allows stacking of layout keywords.

Inside a LayoutContext the sequence of Confirmed columns needs to be strictly increasing. 'Tentative columns between Confirmed columns need to be strictly increasing as well.

Constructors

  • Tentative

    The token defining the layout column was on the same line as the layout keyword and we have not seen a new line yet.

  • Confirmed

    We have seen a new line since the layout keyword and the layout column has not been superseded by a smaller column.

Instances2Eq, Show

Running the parser

5 declarations

Manipulating the state

8 declarations

Layout

Errors

Fake a parse error at the specified position. Used, for instance, when lexing nested comments, which when failing will always fail at the end of the file. A more informative position is the beginning of the failing comment.

valuelexError :: String -> Parser a
#

For lexical errors we want to report the current position as the site of the error, whereas for parse errors the previous position is the one we're interested in (since this will be the position of the token we just lexed). This function does parseErrorAt the current position.