- module
- literals
- idents
- assignments
- operations
- [control flow](#control flow)
- functions
- classes
- [exception handling](#exception handling)
contains a module of code, corresponding to a single file/snippet
Module
code: [Function / Class / Expression]
42
type: module
code:
- type: int
value: 42
contains an int
Int
value: int
42
type: int
value: 42
contains a float
Float
value: float
4.2
type: float
value: 4.2
contains a string
String
value: str
'eyes'
type: string
value: eyes
contains none value
None
None
type: none
contains a list literal
List
elements: [Expression]
[42, None]
type: list
elements:
- type: int
value: 42
- type: none
contains a dictionary literal, the keys are supposed to be numbers or strings or booleans so most target languages can support them natively.
Dict
pairs: [[Hashable, Expression]]
{v: v}
type: dict
pairs:
-
- type: local
name: v
- type: local
name: v
usually a local variable or an argument to the current function
Local
name: str
e #python
e #ruby
type: local
name: e
usually the name of a class or type
Typename
name: str
Animal
type: typename
name: Animal
an instance variable accessed in a method of its class
InstanceVariable
name: str
self.e #python
@e #ruby
type: instance_variable
name: e
an attribute of an object
Attr
object: Expression
attr: str
type: attr
object:
type: int
value: 2
attr: size
an assignment to a local variable (the usual kind of assignment).
Assignment
target: Local
value: Expression
e = 'eyes'
x, y = 2, 4
multi assignments is also supposed to be represented as series of assignment nodes
type: assignment
target:
type: local
name: e
pseudo_type: String
value:
type: string
value: eyes
pseudo_type: String
type: assignment
target:
type: local
name: x
pseudo_type: Int
value:
type: int
value: 2
pseudo_type: Int
type: assignment
target:
type: local
name: y
pseudo_type: Int
value:
type: int
value: 2
pseudo_type: Int
an assignment of ivar
InstanceAssignment
name: str
value: Expression
self.e = e # python
@e = e # ruby
type: instance_assignment
name: e
value:
type: local
name: e
an assignment to attr
AttrAssignment
attribute: Attribute
value: Expression
a.i = None # python
$a->i = NULL; # php
type: attr_assignment
attribute:
type: Attribute
object:
type: local
name: a
name: i
value:
type: none
a function call
Call
function: Expression
args: [Expression]
analyze(e, 2)
type: call
function:
type: local
name: analyze
args:
- type: local
name: e
- type: int
value: 2
a call to an object's method
MethodCall
receiver: Expression
message: str
args: [Expression]
h.analyze()
type: method_call
receiver:
type: local
name: h
message: analyze
args: []
a call to a standard pseudo function pseudo standard functions are divided in namespaces, they in a combination with standard methods (below) represent the pseudo standard library the standard library corresponds to the only pseudo-translateable native functions and methods(builtin in the input/target language or its standard library) if you want support for other functions/methods, please follow the extend pseudo guide
the namespaces currently are global
(no namespace/top namespace) math
, io
, system
you can read more in standard library reference
StandardCall
namespace: None / str
function: str
args: [Expression]
print(2)
type: standard_call
namespace: io
function: display
args:
- type: int
value: 2
a pseudo standard library method call the standard library corresponds to the only pseudo-translateable native functions and methods(builtin in the input/target language or its standard library) if you want support for other functions/methods, please follow the extend pseudo guide
you can read more in standard library reference
python
StandardMethodCall
receiver: Expression
message: str
args: [Expression]
f()[1:] # f returns a list of int
type: standard_method_call
receiver:
type: call
function:
type: local
name: f
args: []
pseudo_type: List[Int]
message: slice_from
args:
- type: int
value: 1
pseudo_type: List[Int]