File has text format, consists of printed prefix tree and list of variables.
My tree file is named similar to source and has extension .tree
- The complete bracket sequence. Node
(value left_subtree right_subtree)
- No subtree:
_
<type of data> <data>
Type of data in {1,2,3}
1
: Operator, data - code in table for each operator in language2
: Number, data - number, int/double in format1.0
3
: Variable, data - index in table of variables
Name/Priority | Code | Type | Description | Equavalent in C |
---|---|---|---|---|
FUNC_DEF | 10 | Binary | Operator of function definition(body).
|
int summ(int a, int b){...} |
FUNC_DEF_HELP | 11 | Binary | Operator of additional node in function definition.
|
- |
CALL | 12 | Binary | Operator of calling function.
|
summ(a,b); |
RETURN | 13 | Unary | Operator of return in function.
|
return |
DIVIDER | 20 | Binary | Operator of dividing instruction.
|
; |
DIVIDER_ARG | 21 | Binary | Operator of dividing vars in enumeration.
|
, |
EQUAL | 22 | Binary | Operator of dividing instruction
|
; |
VAR | 100 | Binary | Operator of init or assignment variables.
|
int x; |
VOID | 101 | Empty | Operator for return value of function.NULL NULL |
void |
IF | 102 | Binary | Operator of condition.
|
if |
WHILE | 103 | Binary | Operator of loop.
|
while |
ELSE | 104 | Binary | Operator of
|
else |
BREAK | 105 | Binary | Operator of break in loop.NULL NULL |
break |
CONTINUE | 106 | Binary | Operator of continue in loop.NULL NULL |
continue |
ZERO | 30 | Binary | Operator of expression | > |
ZERO | 31 | Binary | Operator of expression | < |
ZERO | 32 | Binary | Operator of expression | >= |
ZERO | 33 | Binary | Operator of expression | <= |
ZERO | 34 | Binary | Operator of expression | != |
ZERO | 35 | Binary | Operator of expression | == |
FIRST | 40 | Binary | Operator of expression | + |
FIRST | 41 | Binary | Operator of expression | - |
FIRST | 42 | Binary | Operator of expression | || |
SECOND | 50 | Binary | Operator of expression | && |
SECOND | 51 | Binary | Operator of expression | % |
SECOND | 52 | Binary | Operator of expression | * |
SECOND | 53 | Binary | Operator of expression | / |
FOURTH | 70 | Unary | Operator of expression | ++ |
FOURTH | 71 | Unary | Operator of expression | -- |
FOURTH | 72 | Unary | Operator of expression | ! |
After tree its place for list of variables
<index(begin with 0)> <name_of_varible>
Code:
var x;
var y = x+1;
if (1) {
print(x);
}
Tree:
(1 21 (1 21 (1 21 (1 100 _ (3 0 _ _ )) _ )(1 100 _ (1 20 (3 1 _ _ )(1 40 (3 0 _ _ )(2 1 _ _ )))))(1 102 (2 1 _ _ )(1 21 (1 12 (3 2 _ _ )(3 0 _ _ )) _ )))
0 x
1 y
2 print