| Portability | GHC-only |
|---|---|
| Stability | experimental |
| Maintainer | Fontaine@cs.uni-duesseldorf.de |
Language.CSPM.Frontend
Description
Frontend contains some reexports from other modules
- testFrontend :: FilePath -> IO (LModule, LModule)
- parseFile :: FilePath -> IO LModule
- data Token
- lexInclude :: String -> IO (Either LexError [Token])
- lexPlain :: String -> Either LexError [Token]
- filterIgnoredToken :: [Token] -> [Token]
- data LexError = LexError {}
- parse :: SourceName -> [Token] -> Either ParseError LModule
- data ParseError = ParseError {}
- data Module
- type LModule = Labeled Module
- data Labeled t = Labeled {}
- type Bindings = Map String UniqueIdent
- data SrcLoc
- = TokIdPos TokenId
- | TokIdSpan TokenId TokenId
- | TokSpan Token Token
- | TokPos Token
- | NoLocation
- | FixedLoc {
- fixedStartLine :: !Int
- fixedStartCol :: !Int
- fixedStartOffset :: !Int
- fixedLen :: !Int
- fixedEndLine :: !Int
- fixedEndCol :: !Int
- fixedEndOffset :: !Int
- getRenaming :: LModule -> Either RenameError (Bindings, AstAnnotation UniqueIdent, AstAnnotation UniqueIdent)
- applyRenaming :: (Bindings, AstAnnotation UniqueIdent, AstAnnotation UniqueIdent) -> LModule -> LModule
- removeSourceLocations :: LModule -> LModule
- removeParens :: LModule -> LModule
- removeModuleTokens :: LModule -> LModule
- unUniqueIdent :: LModule -> LModule
- showAst :: Data a => Labeled a -> String
- relabelAst :: NodeId -> LModule -> LModule
- computeFreeNames :: Data a => a -> FreeNames
- data RenameError = RenameError {}
- eitherToExc :: Exception a => Either a b -> IO b
- handleLexError :: (LexError -> IO a) -> IO a -> IO a
- handleParseError :: (ParseError -> IO a) -> IO a -> IO a
- handleRenameError :: (RenameError -> IO a) -> IO a -> IO a
- compilePattern :: LModule -> LModule
- version :: IO String
- pp :: PP x => x -> Doc
Documentation
parseFile :: FilePath -> IO LModuleSource
Lex and parse a file and return a LModule, throw an exception in case of an error
filterIgnoredToken :: [Token] -> [Token]Source
parse :: SourceName -> [Token] -> Either ParseError LModuleSource
The parse function parses a List of Token.
It returns a ParseError or a Labled Module.
The SourceName argument is currently not used.
type Bindings = Map String UniqueIdentSource
Constructors
| TokIdPos TokenId | |
| TokIdSpan TokenId TokenId | |
| TokSpan Token Token | |
| TokPos Token | |
| NoLocation | |
| FixedLoc | |
Fields
| |
getRenaming :: LModule -> Either RenameError (Bindings, AstAnnotation UniqueIdent, AstAnnotation UniqueIdent)Source
getRenaming computes two AstAnnotations.
The first one contains all the defining occurences of identifier
The second one contains all the using occurences of identitier.
getRename returns an RenameError if the Module contains unbound
identifiers or illegal redefinitions.
applyRenaming :: (Bindings, AstAnnotation UniqueIdent, AstAnnotation UniqueIdent) -> LModule -> LModuleSource
applyRenaming uses SYB to replace turn every Ident in the Module into to the
UIdent version, i.e. set the UniqueIdent.
At the same time, we also replace VarPat x with ConstrPat x if x an toplevel constant
It is an error if the Module contains occurences of Ident that are not covered by
the AstAnnotations.
removeSourceLocations :: LModule -> LModuleSource
removeSourceLocations sets all locationsInfos to NoLocation
removeParens :: LModule -> LModuleSource
removeParens removes all occurences of of Parens,i.e. explicit parentheses from the AST
removeModuleTokens :: LModule -> LModuleSource
set the tokenlist in the module datatype to Nothing
unUniqueIdent :: LModule -> LModuleSource
unUniqueIdent replaces the all UIdent with the Ident of the the new name, thus forgetting | additional information like the bindingside, etc. | Usefull to get a smaller AST.
showAst :: Data a => Labeled a -> StringSource
'a show function that omits the node labeles. | TODO : fix this is very buggy. | this does not work for Compiles pattern / Arrays
relabelAst :: NodeId -> LModule -> LModuleSource
relabelAst compute an AST with new NodeIds starting with the given NodeId
computeFreeNames :: Data a => a -> FreeNamesSource
Compute the FreeNames of an Expression. | This function does only work after renaming has been done. | This implementation is inefficient.
data RenameError Source
Constructors
| RenameError | |
Fields | |
eitherToExc :: Exception a => Either a b -> IO bSource
eitherToExe returns the Right part of Either or throws the Left part as an dynamic exception.
handleLexError :: (LexError -> IO a) -> IO a -> IO aSource
Handle a dymanic exception of type LexError.
handleParseError :: (ParseError -> IO a) -> IO a -> IO aSource
Handle a dymanic exception of type ParseError.
handleRenameError :: (RenameError -> IO a) -> IO a -> IO aSource
Handle a dymanic exception of type RenameError.
compilePattern :: LModule -> LModuleSource
replace all pattern in the module with list of linear Selectors