The Quipper System

Safe HaskellNone

QuipperLib.QuipperASCIIParser.Parse

Contents

Description

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.

Synopsis

Documentation

data GatePlus Source

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

Instances

Parsing

string_literal :: ReadP StringSource

Parse a string literal.

escaped_char :: ReadP CharSource

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

int :: ReadP IntSource

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

double :: ReadP DoubleSource

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 BoolSource

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

label' :: ReadP (Int, String)Source

Consume a label.

labelchar :: ReadP StringSource

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

labelbracket :: ReadP StringSource

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

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

Consume a list of labels.

box_id :: ReadP BoxIdSource

Consume a BoxId followed by a ']' character.

nocontrolflag :: ReadP NoControlFlagSource

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

ascii_line :: ReadP GatePlusSource

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 GatePlusSource

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