free-compiler-0.3.0.0: A Haskell to Coq compiler.

Safe HaskellSafe
LanguageHaskell2010

FreeC.Frontend.IR.Parser

Description

This module contains a parser for our intermediate representation (IR).

The intermediate language is usually not parsed directly. It is more common for another language (e.g., Haskell) to be parsed and converted to out intermediate language. The main purpose of the IR parser is to easily construct AST nodes in unit tests without making the tests dependent on some front end for the construction of the AST.

The syntax of the intermediate language is based on Haskell. However, there is only very little syntactic sugar. For example, there are no infix operations, all applications are written in prefix notation. Since the unary minus is actually syntactic sugar for negate in Haskell, there is also no unary minus in the intermediate representation. Furthermore, the intermediate language does not implement Haskell's layout rule.

The parser does not support source spans at the moment, all generated nodes are annotated with NoSrcSpan.

Synopsis

Documentation

class Parseable a where Source #

Type class for IR nodes that can be parsed.

Methods

parseIR' :: Parser a Source #

The parser to use for IR nodes of type a.

This parser should not consume EOF such that it can still be combines with other parsers. Use parseIR to parse an entire input string instead.

Instances
Parseable QName Source #

Qualifiable names can be parsed.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser QName Source #

Parseable Name Source #

Names can be parsed.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser Name Source #

Parseable Type Source #

Type expressions can be parsed.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser Type Source #

Parseable TypeScheme Source #

Parser for IR type schemes.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser TypeScheme Source #

Parseable TypeDecl Source #

Data type and type synonym declarations can be parsed.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser TypeDecl Source #

Parseable Expr Source #

Expressions can be parsed.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser Expr Source #

Parseable FuncDecl Source #

Function declarations can be parsed.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser FuncDecl Source #

Parseable TypeSig Source # 
Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser TypeSig Source #

Parseable ImportDecl Source #

Import declarations can be parsed.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser ImportDecl Source #

Parseable (ModuleOf [TopLevelDecl]) Source #

Modules can be parsed.

Instance details

Defined in FreeC.Frontend.IR.Parser

Methods

parseIR' :: Parser (ModuleOf [TopLevelDecl]) Source #

parseIR :: (Parseable a, MonadReporter r) => SrcFile -> r a Source #

Parses an IR node of type a and reports parsing errors.

Leading white spaces and comments are ignored. The full input must be consumed otherwise a fatal error is reported.