-
Notifications
You must be signed in to change notification settings - Fork 1
/
newGrammar.txt
55 lines (38 loc) · 1.93 KB
/
newGrammar.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<code> -> <func> <other_code>
<other_code> -> $ | <code>
<func> -> <return_type> <id> ( <idlist> ) { <explist> }
<return_type> -> <var_type> | void
<var_type> -> int | string | char | float
<idlist> -> <id_decl> <other_decl> | $
<id_decl> -> <var_type> <id>
<other_decl> -> , <id_decl> <other_decl> | $
<explist> -> <expression> <explist> | $
<expression> -> <decl_action> | <op_action> | <IO_call> | <cycle> | <condition> | <return_call>
<decl_action> -> <var_decl> <decl_right> ; | <map_decl> ;
<var_decl> -> <var_type> <id> <array_part>
<map_decl> -> map '<' <var_type> , <var_type> '>' <id>
<array_part> -> $ | [ <right_part> ] <second_dimension>
<second_dimension> -> $ | [ <right_part> ]
<decl_right> -> = <right_part> | $
<right_part> -> <right_part> <low_prior_bin_op> <mult> | <mult>
<mult> -> <mult> <high_prior_bin_op> <exp_part> | <exp_part>
<exp_part> -> ( <right_part> ) | - ( <right_part> ) | <left_part> | - <left_part> | <const>
<const> -> <const_int> | <const_string> | <const_float> | <const_char>
<low_prior_bin_op> -> + | - | '|' | %
<high_prior_bin_op> -> * | / | &
<op_action> -> <left_part_wo_functions> = <right_part> ;
<left_part_wo_functions> -> <id> <array_part>
<left_part> -> <id> <next_part>
<next_part> -> <array_part> | ( <func_list> )
<func_list> -> $ | <right_part> <other_func_list>
<other_func_list> -> $ | , <right_part> <other_func_list>
<IO_call> -> cin >> <left_part_wo_functions> ; | cout << <right_part> ;
<cycle> -> while ( <cond_expr> ) { <explist> } | for ( <var_decl> = <right_part> ; <cond_expr> ; <id> = <right_part> ) { <explist> }
<cond_expr> -> <cond_expr> <bool_op> <rel_expr> | <rel_expr>
<rel_expr> -> <exp_cond_part> <rel_op> <exp_cond_part>
<exp_cond_part> -> ( <cond_expr> ) | ! ( <cond_expr> ) | <right_part>
<bool_op> -> && | '||'
<rel_op> -> == | != | > | < | >= | <=
<condition> -> if ( <cond_expr> ) { <explist> } <else>
<else> -> $ | else { <explist> }
<return_call> -> return <right_part> ;