| Copyright | (c) Sebastian Galkin 2018 |
|---|---|
| License | GPL-3 |
| Safe Haskell | None |
| Language | Haskell2010 |
HBF.Parser
Contents
Synopsis
- program :: Parser (Program Unoptimized)
- operation :: Parser Op
- bfSimpleTokens :: String
- bfTokens :: String
- garbage :: Parser Char
- simpleOp :: Parser Op
- loopOp :: Parser Op
- parseProgram :: Text -> Either ParseError (Program Unoptimized)
- data ParseError
Documentation
program :: Parser (Program Unoptimized) Source #
Parser for a full Program.
>>>isRight $ parse program " +[->>+ +[<] ##garbage## ],.[-] can ignore garbage"True
operation :: Parser Op Source #
Parser for an Op, ignoring unknown characters.
>>>parse operation " +///"Right (Inc 1 0)
>>>parse operation "fooo [+>] baaar "Right (Loop [Inc 1 0,Move 1])
bfSimpleTokens :: String Source #
The characters allowed in a Brainfuck program except for the loop characters [ and ].
garbage :: Parser Char Source #
Parser for unknown characters
>>>parse garbage "this is @#! garbage"Right 't'
>>>isLeft $ parse garbage "+"True
simpleOp :: Parser Op Source #
Parser for simple operations (not loops).
>>>parse simpleOp ">"Right (Move 1)
>>>parse simpleOp "."Right (Out 1 0)
Parser for loops.
>>>parse loopOp "[+-]"Right (Loop [Inc 1 0,Inc (-1) 0])
parseProgram :: Text -> Either ParseError (Program Unoptimized) Source #
Parse program stream. Returns an error or the parsed Program
Reexport from Text.Parsec
data ParseError #
The abstract data type ParseError represents parse errors. It
provides the source position (SourcePos) of the error
and a list of error messages (Message). A ParseError
can be returned by the function parse. ParseError is an
instance of the Show and Eq classes.
Instances
| Eq ParseError | |
Defined in Text.Parsec.Error | |
| Show ParseError | |
Defined in Text.Parsec.Error Methods showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # | |