htcc-0.0.0.1: The full scratch implementation of tiny C compiler (x86_64)
Copyright(c) roki 2019
LicenseMIT
Maintainerfalgon53@yahoo.co.jp
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Htcc.Utils.CompilationState

Description

General-purpose utilities

Synopsis

Documentation

type CompilationState cd inp i r = StateT (cd, inp) (Either (ASTError i)) r Source #

The state type handled during compilation. It has informations required during the compilation process and input data consumed.

itemP :: MonoFoldable mono => CompilationState cd mono i (Maybe (Element mono)) Source #

itemP peeks at one item from input data

itemsP :: (MonoFoldable mono, IsSequence mono) => Index mono -> CompilationState cd mono i (Maybe mono) Source #

itemsP peeks at items from input data

itemC :: IsSequence mono => (cd -> Element mono -> cd) -> CompilationState cd mono i (Maybe (Element mono)) Source #

itemC consumes at one item from input data. Defines information updates by providing a function that accepts the current information and one item to be consumed and returns the information

itemsC :: IsSequence mono => (cd -> Element mono -> cd) -> Int -> CompilationState cd mono i (Maybe mono) Source #

itemsC consumes at items from input data. Defines information updates by providing a function that accepts the current information and one item to be consumed and returns the information

curCD :: CompilationState cd mono i cd Source #

curCD gets current information

itemCWhen :: (MonoFoldable mono, IsSequence mono) => (cd -> Element mono -> cd) -> (Element mono -> Bool) -> CompilationState cd mono i (Maybe (Element mono)) Source #

itemCWhen consumes an item when the unary function satisfies the given condition. Defines information updates by providing a function that accepts the current information and one item to be consumed and returns the information

itemsCWhen :: (MonoFoldable mono, IsSequence mono) => (cd -> Element mono -> cd) -> (Element mono -> Bool) -> CompilationState cd mono i mono Source #

itemsCWhen consumes items when the unary function satisfies the given condition. Defines information updates by providing a function that accepts the current information and one item to be consumed and returns the information

isSatisfied :: (mono -> Bool) -> CompilationState cd mono i Bool Source #

isSatisfied returns True if the input data satisfies the condition of given unary function, otherwise returns False.