The Quipper System

Safe HaskellNone




This module contains the code for parsing the ASCII output from Quipper, into a GatePlus. This program is heavily based on, and heavily borrows from the QCLParser.



data GatePlus Source #

A type for gates, plus other circuit output, empty lines, and subroutine defs.



string_literal :: ReadP String Source #

Parse a string literal.

escaped_char :: ReadP Char Source #

Parse an escaped character, such as 0, n, \, etc.

int :: ReadP Int Source #

Parse a signless integer. We avoid the usual trick (readS_to_P reads), because this introduces backtracking errors.

double :: ReadP Double Source #

Parse a floating point number. We avoid the usual trick (readS_to_P reads), because this introduces backtracking errors.

commalist :: ReadP a -> ReadP [a] Source #

Parse a comma separated list.

control :: ReadP (Signed Wire, Wiretype) Source #

Parse a control structure.

controls :: ReadP ([Signed Wire], [(Wire, Wiretype)]) Source #

Parse a list of controls.

wire :: ReadP (Int, Wiretype) Source #

Parse a wire and its type.

wires :: ReadP [(Int, Wiretype)] Source #

Parse a list of input/output wires and types.

none :: ReadP [(Int, Wiretype)] Source #

Parse the string "none", returning an empty list of input/output wires and types.

inversechar :: ReadP Bool Source #

Consume an optional "*". Return True if consumed, and False otherwise.

label' :: ReadP (Int, String) Source #

Consume a label.

labelchar :: ReadP String Source #

Consumer any character other than ')', ']', or ','.

labelbracket :: ReadP String Source #

Consume an index of the form [...].

labels :: ReadP [(Int, String)] Source #

Consume a list of labels.

box_id :: ReadP BoxId Source #

Consume a BoxId followed by a ']' character.

nocontrolflag :: ReadP NoControlFlag Source #

Consume an optional NoControlFlag, returning False if it isn't present.

ascii_line :: ReadP GatePlus Source #

Parse a single line of ASCII output into a Gate. This function needs to be kept in line with Quipper's ascii_render_gate function.

parse_ascii_line :: String -> Maybe GatePlus Source #

The overall parsing function, reading a line of ASCII output, and producing a GatePlus.