| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Quipper.Libraries.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
- data GatePlus
- = G Gate [(Wire, Wiretype)]
- | I [(Wire, Wiretype)]
- | O [(Wire, Wiretype)]
- | EmptyLine
- | CommentLine String
- | SubroutineName String
- | SubroutineShape String
- | Controllable ControllableFlag
- string_literal :: ReadP String
- escaped_char :: ReadP Char
- int :: ReadP Int
- double :: ReadP Double
- commalist :: ReadP a -> ReadP [a]
- control :: ReadP (Signed Wire, Wiretype)
- controls :: ReadP ([Signed Wire], [(Wire, Wiretype)])
- wiretype :: ReadP Wiretype
- wire :: ReadP (Int, Wiretype)
- wires :: ReadP [(Int, Wiretype)]
- none :: ReadP [(Int, Wiretype)]
- inversechar :: ReadP Bool
- label' :: ReadP (Int, String)
- labelchar :: ReadP String
- labelbracket :: ReadP String
- labels :: ReadP [(Int, String)]
- box_id :: ReadP BoxId
- nocontrolflag :: ReadP NoControlFlag
- ascii_line :: ReadP GatePlus
- parse_ascii_line :: String -> Maybe GatePlus
Documentation
A type for gates, plus other circuit output, empty lines, and subroutine defs.
Constructors
| G Gate [(Wire, Wiretype)] | |
| I [(Wire, Wiretype)] | |
| O [(Wire, Wiretype)] | |
| EmptyLine | |
| CommentLine String | |
| SubroutineName String | |
| SubroutineShape String | |
| Controllable ControllableFlag |
Parsing
string_literal :: ReadP String Source #
Parse a string literal.
escaped_char :: ReadP Char Source #
Parse an escaped character, such as 0, n, \, etc.
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.
none :: ReadP [(Int, Wiretype)] Source #
Parse the string "none", returning an empty list of input/output wires and types.
inversechar :: ReadP Bool Source #
labelbracket :: ReadP String Source #
Consume an index of the form [...].
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.