Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Identifier = String
- type Content = String
- data SyntaxTree = SyntaxTree {
- identifier :: !Identifier
- content :: !Content
- position :: !SourcePos
- children :: ![SyntaxTree]
- flattenSyntaxTree :: SyntaxTree -> [SyntaxTree]
- findST :: (SyntaxTree -> Bool) -> SyntaxTree -> Maybe SyntaxTree
- replaceIdentifier :: Identifier -> SyntaxTree -> SyntaxTree
- replaceContent :: Content -> SyntaxTree -> SyntaxTree
- replacePosition :: SourcePos -> SyntaxTree -> SyntaxTree
- replaceChildren :: [SyntaxTree] -> SyntaxTree -> SyntaxTree
- insert :: SyntaxTree -> SyntaxTree -> SyntaxTree
- remove :: SyntaxTree -> SyntaxTree -> SyntaxTree
- collapse :: (SyntaxTree -> Bool) -> SyntaxTree -> SyntaxTree
- prune :: (SyntaxTree -> Bool) -> SyntaxTree -> SyntaxTree
- pruneUnderscored :: SyntaxTree -> SyntaxTree
- isTerminal :: SyntaxTree -> Bool
- nulltree :: SyntaxTree
Documentation
type Identifier = String Source
data SyntaxTree Source
SyntaxTree | |
|
flattenSyntaxTree :: SyntaxTree -> [SyntaxTree] Source
findST :: (SyntaxTree -> Bool) -> SyntaxTree -> Maybe SyntaxTree Source
replaceIdentifier :: Identifier -> SyntaxTree -> SyntaxTree Source
returns a syntax tree similar to the one passed but with the given identifier.
replaceContent :: Content -> SyntaxTree -> SyntaxTree Source
returns a syntax tree similar to the one passed but with the given content.
replacePosition :: SourcePos -> SyntaxTree -> SyntaxTree Source
returns a syntax tree similar to the one passed but with the given position.
replaceChildren :: [SyntaxTree] -> SyntaxTree -> SyntaxTree Source
returns a syntax tree similar to the one passed but with the given children.
insert :: SyntaxTree -> SyntaxTree -> SyntaxTree Source
inserts a syntax tree as a child, list is sorted by source code position
remove :: SyntaxTree -> SyntaxTree -> SyntaxTree Source
removes any children of st
that equal st'
collapse :: (SyntaxTree -> Bool) -> SyntaxTree -> SyntaxTree Source
the content of the syntax tree is merged with it's parent if the predicate is met.
prune :: (SyntaxTree -> Bool) -> SyntaxTree -> SyntaxTree Source
prune will remove any children of tree
that satisfy predicate
,
recursively
pruneUnderscored :: SyntaxTree -> SyntaxTree Source
prune any children of st
whose identifier begins with an underscore.
might be useful for preventing syntax trees from being polluted by
base cases of single characters by annotating the EBNF definition of
single-char base cases such as single letters as `_letters_ = ...`
isTerminal :: SyntaxTree -> Bool Source