Skip to content

Latest commit

 

History

History
78 lines (63 loc) · 4.11 KB

Standard.md

File metadata and controls

78 lines (63 loc) · 4.11 KB

Standart of file

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

Prefix tree

  • The complete bracket sequence. Node (value left_subtree right_subtree)
  • No subtree: _

Value of node

<type of data> <data>

Type of data in {1,2,3}

  • 1: Operator, data - code in table for each operator in language
  • 2: Number, data - number, int/double in format 1.0
  • 3: Variable, data - index in table of variables

Table of operators

Name/Priority Code Type Description Equavalent in C
FUNC_DEF 10 Binary Operator of function definition(body).
  • Left node - FUNC_DEF_HELP
    • Left Node - type of ret(var/void)
    • Right Node - var(name of function)
  • Right node - FUNC_DEF_HELP
    • Left Node - subtree of vars-arguments and DIVIDER_ARG
    • Right Node - instructions
    int summ(int a, int b){...}
    FUNC_DEF_HELP 11 Binary Operator of additional node in function definition.
    • Left node - subtree
    • Right node - subtree
    -
    CALL 12 Binary Operator of calling function.
    • Left node - var(name of function)
    • Right node - subtree of vars-arguments and DIVIDER_ARG
    summ(a,b);
    RETURN 13 Unary Operator of return in function.
    • Left node - var(name of ret var) or NULL
    • Right node - NULL
    return
    DIVIDER 20 Binary Operator of dividing instruction.
    • Left node - instruction
    • Right node - DIVIDER or NULL
    ;
    DIVIDER_ARG 21 Binary Operator of dividing vars in enumeration.
    • Left node - var(in list)
    • Right node - DIVIDER_ARG or NULL
    ,
    EQUAL 22 Binary Operator of dividing instruction
    • Left node - instruction
    • Right node - DIVIDER or NULL
    ;
    VAR 100 Binary Operator of init or assignment variables.
    • Left node - NULL
    • Right node - subtree:
      EQUAL
      • Left Node - var in assignment
      • Right Node - expression
    int x;
    VOID 101 Empty Operator for return value of function.
    NULL NULL
    void
    IF 102 Binary Operator of condition.
    • Left node - expression
    • Right Node - instructions(if condition is true) or subtree:
      ELSE
      • Left Node - instructions(if condition is true)
      • Right Node - instructions(if condition is false)
    if
    WHILE 103 Binary Operator of loop.
    • Left node - expression
    • Right Node - instructions(if condition is true)
    while
    ELSE 104 Binary Operator of
    • Left Node - instructions(if condition is true)
    • Right Node - instructions(if condition is false)
    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 !

    List of variables

    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