qute-syntax-0.1.0: This package provides a parser for the QBE intermediate language.
Safe HaskellNone
LanguageGHC2021

Language.QBE

Description

This module provides top-level definitions for representing programs written in the QBE intermediate representation.

Synopsis

Documentation

type Program = [Definition] Source #

A parsed QBE program, represented as a list of Definition values.

data Definition Source #

A QBE program consists of a sequence of definitions. Four types of objects can be defined: aggregate types, data, functions, and debugging information.

See also: The corresponding section of the QBE specification.

Constructors

DefData DataDef

Definition of data (e.g. a string).

DefType TypeDef

Definition of an aggregate data type.

DefFunc FuncDef

Definition of a function.

DefFile String

Definition of a debug file.

Instances

Instances details
Show Definition Source # 
Instance details

Defined in Language.QBE

Eq Definition Source # 
Instance details

Defined in Language.QBE

globalFuncs :: Program -> [FuncDef] Source #

Utility function to obtain all functions defined in a QBE Program.

parse :: SourceName -> String -> Either ParseError Program Source #

Wrapper to parse a QBE program using parse.

data ExecError Source #

Custom Exception used for error handling in parseAndFind.

Constructors

ESyntaxError ParseError

The input is not a valid QBE program.

EUnknownEntry GlobalIdent

The given entry function is not defined in the QBE program.

Instances

Instances details
Exception ExecError Source # 
Instance details

Defined in Language.QBE

Show ExecError Source # 
Instance details

Defined in Language.QBE

parseAndFind :: MonadThrow m => GlobalIdent -> String -> m (Program, FuncDef) Source #

Utility function for the common task of parsing an input as a QBE Program and, within that program, finding the entry function. If the function doesn't exist or a the input is invalid a ExecError exception is thrown.