Cnorm AST¶
This module provide all AST nodes.
-
class
cnorm.nodes.
Func
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Expr
For almost everything
-
to_c
(self)¶
-
-
class
cnorm.nodes.
BlockInit
(body: [<class 'cnorm.nodes.Expr'>])[source]¶ Bases:
cnorm.nodes.Expr
Initializer Block Expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
BlockExpr
(body: [<class 'cnorm.nodes.Expr'>])[source]¶ Bases:
cnorm.nodes.Expr
Compound Block Expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Unary
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Func
For unary operator
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Paren
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Unary
For () expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Array
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Unary
For [] expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Dot
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Unary
For . expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Arrow
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Unary
For -> expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Post
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Unary
For post{inc,dec} expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Sizeof
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Unary
For sizeof expr/type expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Binary
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Func
For binary operator
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Cast
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Binary
For cast operator
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Range
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Binary
For range expression
-
class
cnorm.nodes.
Ternary
(call_expr: cnorm.nodes.Expr, params: list)[source]¶ Bases:
cnorm.nodes.Func
For ternary operator
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Terminal
(value: str)[source]¶ Bases:
cnorm.nodes.Expr
For Terminal expression
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Id
(value: str)[source]¶ Bases:
cnorm.nodes.Terminal
Terminal Id
-
class
cnorm.nodes.
Literal
(value: str)[source]¶ Bases:
cnorm.nodes.Terminal
Terminal Literal
-
class
cnorm.nodes.
Raw
(value: str)[source]¶ Bases:
cnorm.nodes.Terminal
Terminal Raw
-
class
cnorm.nodes.
Enumerator
(ident: str, expr: cnorm.nodes.Expr)[source]¶ Bases:
pyrser.parsing.node.Node
Enumerator A=x in enums
-
class
cnorm.nodes.
PointerType
[source]¶ Bases:
cnorm.nodes.DeclType
For pointer in declaration
-
class
cnorm.nodes.
ArrayType
(expr=None)[source]¶ Bases:
cnorm.nodes.DeclType
For array in declaration
-
expr
¶
-
-
class
cnorm.nodes.
ParenType
(params=None)[source]¶ Bases:
cnorm.nodes.DeclType
For parenthesis in declaration
-
params
¶
-
-
class
cnorm.nodes.
QualType
(qualifier: pyrser.meta.Enum=0)[source]¶ Bases:
cnorm.nodes.DeclType
For qualifier in declaration
-
class
cnorm.nodes.
AttrType
(raw: str)[source]¶ Bases:
cnorm.nodes.DeclType
For attribute specifier in declaration
-
class
cnorm.nodes.
CType
[source]¶ Bases:
pyrser.parsing.node.Node
Base for primary/func
-
ctype_to_c
(self, func_var_name= '')¶
-
-
class
cnorm.nodes.
PrimaryType
(identifier: str)[source]¶ Bases:
cnorm.nodes.CType
For primary type in declaration
-
identifier
¶
-
-
class
cnorm.nodes.
ComposedType
(identifier: str)[source]¶ Bases:
cnorm.nodes.CType
For composed type in declaration
-
identifier
¶
-
-
class
cnorm.nodes.
FuncType
(identifier: str, params=[], decltype=None)[source]¶ Bases:
cnorm.nodes.PrimaryType
For function in declaration
-
params
¶
-
-
class
cnorm.nodes.
Decl
(name: str, ct=None)[source]¶ Bases:
cnorm.nodes.Expr
For basic declaration
A declaration contains the following attributes:
- _name: name of the declaration
- _ctype: the CType describing the type of the declaration
- _assign_expr: when the declaration have a value
- _colon_expr: When it’s a bitfield
- body: when it’s function definition
-
ctype
¶
-
to_c
(self)¶
-
class
cnorm.nodes.
ExprStmt
(expr: cnorm.nodes.Expr)[source]¶ Bases:
cnorm.nodes.Stmt
Expression statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
BlockStmt
(body: [<class 'cnorm.nodes.ExprStmt'>])[source]¶ Bases:
cnorm.nodes.Stmt
Block statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
RootBlockStmt
(body: [<class 'cnorm.nodes.ExprStmt'>])[source]¶ Bases:
cnorm.nodes.BlockStmt
Root Block statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Label
(value: str)[source]¶ Bases:
cnorm.nodes.Stmt
Label statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Branch
(value: str, expr: cnorm.nodes.Expr)[source]¶ Bases:
cnorm.nodes.Label
branch statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Case
(expr: cnorm.nodes.Expr)[source]¶ Bases:
cnorm.nodes.Branch
Case statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Return
(expr: cnorm.nodes.Expr)[source]¶ Bases:
cnorm.nodes.Branch
Return statement
-
class
cnorm.nodes.
Goto
(expr: cnorm.nodes.Expr)[source]¶ Bases:
cnorm.nodes.Branch
Goto statement
-
class
cnorm.nodes.
LoopControl
(value: str)[source]¶ Bases:
cnorm.nodes.Label
loop control statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Break
[source]¶ Bases:
cnorm.nodes.LoopControl
break statement
-
class
cnorm.nodes.
Continue
[source]¶ Bases:
cnorm.nodes.LoopControl
continue statement
-
class
cnorm.nodes.
Conditional
(condition: cnorm.nodes.Expr)[source]¶ Bases:
cnorm.nodes.Stmt
Conditional statement
-
class
cnorm.nodes.
If
(condition: cnorm.nodes.Expr, thencond: cnorm.nodes.Stmt, elsecond: cnorm.nodes.Stmt=None)[source]¶ Bases:
cnorm.nodes.Conditional
If statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
While
(condition: cnorm.nodes.Expr, body: cnorm.nodes.Stmt)[source]¶ Bases:
cnorm.nodes.Conditional
While statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Switch
(condition: cnorm.nodes.Expr, body: cnorm.nodes.Stmt)[source]¶ Bases:
cnorm.nodes.Conditional
Switch statement
-
to_c
(self)¶
-
-
class
cnorm.nodes.
Do
(condition: cnorm.nodes.Expr, body: cnorm.nodes.Stmt)[source]¶ Bases:
cnorm.nodes.Conditional
Do statement
-
to_c
(self)¶
-