Copyright | (c) roki 2019 |
---|---|
License | MIT |
Maintainer | falgon53@yahoo.co.jp |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
The AST data type and its utilities
Synopsis
- data ATKindFor a
- data ATKind a
- = ATAdd
- | ATAddPtr
- | ATSub
- | ATSubPtr
- | ATPtrDis
- | ATMul
- | ATDiv
- | ATMod
- | ATAddAssign
- | ATSubAssign
- | ATMulAssign
- | ATDivAssign
- | ATAddPtrAssign
- | ATSubPtrAssign
- | ATLAnd
- | ATLOr
- | ATAnd
- | ATAndAssign
- | ATOr
- | ATOrAssign
- | ATXor
- | ATXorAssign
- | ATBitNot
- | ATShl
- | ATShlAssign
- | ATShr
- | ATShrAssign
- | ATLT
- | ATLEQ
- | ATGT
- | ATGEQ
- | ATEQ
- | ATNEQ
- | ATNot
- | ATAddr
- | ATDeref
- | ATAssign
- | ATPreInc
- | ATPreDec
- | ATPostInc
- | ATPostDec
- | ATNum a
- | ATConditional (ATree a) (ATree a) (ATree a)
- | ATComma
- | ATCast
- | ATMemberAcc (StructMember a)
- | ATReturn
- | ATIf
- | ATElse
- | ATSwitch (ATree a) [ATree a]
- | ATCase a a
- | ATDefault a
- | ATWhile
- | ATFor [ATKindFor a]
- | ATBreak
- | ATContinue
- | ATGoto Text
- | ATLabel Text
- | ATBlock [ATree a]
- | ATLVar (StorageClass a) a
- | ATGVar (StorageClass a) Text
- | ATDefFunc Text (Maybe [ATree a])
- | ATCallFunc Text (Maybe [ATree a])
- | ATExprStmt
- | ATStmtExpr [ATree a]
- | ATNull (ATree a)
- data ATree a
- class Treealizable a where
- atBinary :: ATKind i -> StorageClass i -> ATree i -> ATree i -> ATree i
- atUnary :: ATKind i -> StorageClass i -> ATree i -> ATree i
- atNoLeaf :: ATKind i -> StorageClass i -> ATree i
- atLVar :: StorageClass i -> i -> ATree i
- atGVar :: StorageClass i -> Text -> ATree i
- atAssign :: ATree i -> ATree i -> ATree i
- atNumLit :: i -> ATree i
- atMemberAcc :: StructMember i -> ATree i -> ATree i
- atExprStmt :: ATree i -> ATree i
- atBlock :: [ATree i] -> ATree i
- atNull :: ATree i -> ATree i
- atDefFunc :: Text -> Maybe [ATree i] -> StorageClass i -> ATree i -> ATree i
- atReturn :: StorageClass i -> ATree i -> ATree i
- atIf :: ATree i -> ATree i -> ATree i
- atElse :: ATree i -> ATree i -> ATree i
- atWhile :: ATree i -> ATree i -> ATree i
- atFor :: [ATKindFor i] -> ATree i
- atBreak :: ATree i
- atContinue :: ATree i
- atSwitch :: ATree i -> [ATree i] -> StorageClass i -> ATree i
- atCase :: i -> i -> ATree i -> ATree i
- atDefault :: i -> ATree i -> ATree i
- atGoto :: Text -> ATree i
- atLabel :: Text -> ATree i
- atComma :: StorageClass i -> ATree i -> ATree i -> ATree i
- atConditional :: StorageClass i -> ATree i -> ATree i -> ATree i -> ATree i
- atCast :: StorageClass i -> ATree i -> ATree i
- isATForInit :: ATKindFor a -> Bool
- isATForCond :: ATKindFor a -> Bool
- isATForStmt :: ATKindFor a -> Bool
- isATForIncr :: ATKindFor a -> Bool
- fromATKindFor :: ATKindFor a -> ATree a
- isComplexAssign :: ATKind a -> Bool
- isEmptyExprStmt :: ATree a -> Bool
- isEmptyReturn :: ATree a -> Bool
- isNonEmptyReturn :: ATree a -> Bool
- mapATKind :: (ATKind i -> ATKind i) -> ATree i -> ATree i
- modifyTypeATKind :: (StorageClass i -> StorageClass i) -> ATKind i -> ATKind i
Abstract tree types and its relational type class
Specially for
syntax tree type
The syntax tree type. Let \(x,y\in\mathbb{N}\), Let \(p\) and \(q\) be pointers to variables \(a\) and \(b\), respectively (p=&a,q=&b
).
ATAdd | \(x+y\): |
ATAddPtr | add operation for pointer \(p+x,x+p\): |
ATSub | \(x-y\): |
ATSubPtr | sub operation for pointer \(p-x\): |
ATPtrDis | The distance of pointers \(p-q\): |
ATMul | \(x\times y\): |
ATDiv | \(x\div y\): |
ATMod | \(x\bmod y\): |
ATAddAssign | addition assignment: |
ATSubAssign | subtraction assignment: |
ATMulAssign | multiplication assignment: |
ATDivAssign | division assignment: |
ATAddPtrAssign | addition assignment for pointer: |
ATSubPtrAssign | subtraction assignment for pointer: |
ATLAnd | logical and: |
ATLOr | logical or: |
ATAnd | bitwise and: |
ATAndAssign | bitwise and assignment: |
ATOr | bitwise or: |
ATOrAssign | bitwise or assignment: |
ATXor | bitwise xor: |
ATXorAssign | bitwise xor assignment: |
ATBitNot | bitwise not: |
ATShl | left shift: |
ATShlAssign | left shift assignment: |
ATShr | right shift: |
ATShrAssign | right shift assignment: |
ATLT | \(x\lt y\): |
ATLEQ | \(x\leq y\): |
ATGT | \(x\gt y\): |
ATGEQ | \(x\geq y\): |
ATEQ | \(x=y\): |
ATNEQ | \(x\not= y\): |
ATNot | not operator |
ATAddr | addressing operator |
ATDeref | dereferencing operator |
ATAssign | assign operator: |
ATPreInc | pre-increment operator: |
ATPreDec | pre-decrement operator: |
ATPostInc | post-increment operator: |
ATPostDec | post-decrement operator: |
ATNum a | The number |
ATConditional (ATree a) (ATree a) (ATree a) | conditional operator: |
ATComma | comma operator: |
ATCast | the cast operation: |
ATMemberAcc (StructMember a) | accessing the member of the |
ATReturn | the |
ATIf | the |
ATElse | the |
ATSwitch (ATree a) [ATree a] | the |
ATCase a a | the |
ATDefault a | the |
ATWhile | the |
ATFor [ATKindFor a] | the |
ATBreak | the |
ATContinue | the |
ATGoto Text | the |
ATLabel Text | the label, it has name of label. |
ATBlock [ATree a] | the compound statement |
ATLVar (StorageClass a) a | the local variable. It has a type information (as |
ATGVar (StorageClass a) Text | the global variable. It has a type information (as |
ATDefFunc Text (Maybe [ATree a]) | the function definition |
ATCallFunc Text (Maybe [ATree a]) | the function call. It has a offset value and arguments ( |
ATExprStmt | the expression of a statement |
ATStmtExpr [ATree a] | the statement of a expression (GNU extension) |
ATNull (ATree a) | indicates nothing to do |
Instances
IncompleteBase ATKind Source # | |
Defined in Htcc.Parser.AST.Core | |
Show a => Show (ATKind a) Source # | |
The data structure of abstract syntax tree
class Treealizable a where Source #
A class whose type can be converted to ATree
Instances
Treealizable LVar Source # | |
Treealizable Enumerator Source # | |
Defined in Htcc.Parser.ConstructionData.Scope.Enumerator treealize :: Enumerator i -> ATree i Source # |
Constructor
atUnary :: ATKind i -> StorageClass i -> ATree i -> ATree i Source #
atUnary
is a shortcut for unary node
atNoLeaf :: ATKind i -> StorageClass i -> ATree i Source #
atNoLeaf
is equivalent to ATNode k t ATEmpty ATEmpty
atAssign :: ATree i -> ATree i -> ATree i Source #
atAssign
is a shortcut for constructing a assign node
atMemberAcc :: StructMember i -> ATree i -> ATree i Source #
atMemberAcc
is a shortcut for constructing a ATMemberAcc
node
atExprStmt :: ATree i -> ATree i Source #
atExprStmt
is a shortcut for constructing a expression statement node
atDefFunc :: Text -> Maybe [ATree i] -> StorageClass i -> ATree i -> ATree i Source #
atDefFunc
is a shortcut for constructing a function node
atReturn :: StorageClass i -> ATree i -> ATree i Source #
atReturn
is a shortcut for constructing a return
node
atWhile :: ATree i -> ATree i -> ATree i Source #
atWhile
is a shortcut for constructing a while
node
atContinue :: ATree i Source #
atContinue
is a shortcut for constructing a continue
node
atSwitch :: ATree i -> [ATree i] -> StorageClass i -> ATree i Source #
atSwitch
is a shortcut for constructing a switch
node
atDefault :: i -> ATree i -> ATree i Source #
atDefault
is a shortcut for constructing a default
node
atComma :: StorageClass i -> ATree i -> ATree i -> ATree i Source #
atComma
is a shortcut for constructing a ,
node
atConditional :: StorageClass i -> ATree i -> ATree i -> ATree i -> ATree i Source #
atConditional
is a shortcut for constructing a ?:
node
atCast :: StorageClass i -> ATree i -> ATree i Source #
atCast
is a shortcut for constructing a cast node
Utilities
isATForInit :: ATKindFor a -> Bool Source #
isATForCond :: ATKindFor a -> Bool Source #
isATForStmt :: ATKindFor a -> Bool Source #
isATForIncr :: ATKindFor a -> Bool Source #
isComplexAssign :: ATKind a -> Bool Source #
isEmptyExprStmt :: ATree a -> Bool Source #
isEmptyExprStmt
returns True
only if both sides of ATExprStmt
are ATEmpty
. Otherwise, returns False
.
isEmptyReturn :: ATree a -> Bool Source #
isNonEmptyReturn :: ATree a -> Bool Source #
modifyTypeATKind :: (StorageClass i -> StorageClass i) -> ATKind i -> ATKind i Source #
applying for StorageClass
of ATLVar
or ATGVar