-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parser for the While language. -- -- Parser for the While language described in Semantics with -- Applications by Nielson and Nielson. @package while-lang-parser @version 0.1.0.0 -- | Provides shared type definitions forming the parsed AST. module Language.While.Types -- | Variables type alias. type Varname = String -- | Arithmetic expressions, including integer division. data Aexp Numeral :: Integer -> Aexp Variable :: Varname -> Aexp Aadd :: Aexp -> Aexp -> Aexp Asub :: Aexp -> Aexp -> Aexp Amul :: Aexp -> Aexp -> Aexp Adiv :: Aexp -> Aexp -> Aexp -- | Boolean expressions. data Bexp Btrue :: Bexp Bfalse :: Bexp Beq :: Aexp -> Aexp -> Bexp Bleq :: Aexp -> Aexp -> Bexp Bneg :: Bexp -> Bexp Band :: Bexp -> Bexp -> Bexp -- | Statements, including try-catch clauses. data Stm Sass :: Varname -> Aexp -> Stm Sskip :: Stm Scomp :: Stm -> Stm -> Stm Sif :: Bexp -> Stm -> Stm -> Stm Swhile :: Bexp -> Stm -> Stm Stry :: Stm -> Stm -> Stm instance Show Aexp instance Eq Aexp instance Show Bexp instance Eq Bexp instance Show Stm instance Eq Stm -- | Provides parsing of while-language code. Supports reading either a -- file or stdin, resulting in an AST. module Language.While.Parser -- | Parse the specified file and return either failure or the program. loadFile :: FilePath -> IO (Either String Stm) -- | Parse stdin and return either failure or the program. loadStdin :: IO (Either String Stm)