-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.txt
More file actions
44 lines (44 loc) · 2.32 KB
/
rules.txt
File metadata and controls
44 lines (44 loc) · 2.32 KB
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
Program -> Declaration-list #call_main $
Declaration-list -> Declaration Declaration-list | EPSILON
Declaration -> Declaration-initial Declaration-prime
Declaration-initial -> #push_type Type-specifier #declare_id ID
Declaration-prime -> Fun-declaration-prime | Var-declaration-prime
Var-declaration-prime -> ; | [ #push_num NUM ] #declare_array ;
Fun-declaration-prime -> #push_function ( #start_func Params #end_func_params ) #save #set_function_info Compound-stmt #return_manual #jump_out #pop_function #end_scope
Type-specifier -> int | void
Params -> #push_type int #declare_id ID Param-prime Param-list | void
Param-list -> , #add_param Param Param-list | EPSILON #add_param
Param -> Declaration-initial Param-prime
Param-prime -> [ ] #declare_entry_array | EPSILON
Compound-stmt -> { #show_scope_start Declaration-list Statement-list #pop_scope }
Statement-list -> Statement Statement-list | EPSILON
Statement -> Expression-stmt | Compound-stmt | Selection-stmt | Iteration-stmt | Return-stmt
Expression-stmt -> Expression ; | #break break ; | ;
Selection-stmt -> if ( Expression ) #save Statement else #jpf_save Statement #jp
Iteration-stmt -> repeat #label Statement until ( Expression ) #until
Return-stmt -> return Return-stmt-prime #return
Return-stmt-prime -> ; | Expression ;
Expression -> Simple-expression-zegond | #id ID B
B -> #push_eq = Expression #assign | [ Expression ] #array_calc H | Simple-expression-prime
H -> #push_eq = Expression #assign | G D C
Simple-expression-zegond -> Additive-expression-zegond C
Simple-expression-prime -> Additive-expression-prime C
C -> #push_op Relop Additive-expression #do_op | EPSILON
Relop -> < | ==
Additive-expression -> Term D
Additive-expression-prime -> Term-prime D
Additive-expression-zegond -> Term-zegond D
D -> #push_op Addop Term #do_op D | EPSILON
Addop -> + | -
Term -> Factor G
Term-prime -> Factor-prime G
Term-zegond -> Factor-zegond G
G -> #push_op * Factor #do_op G | EPSILON
Factor -> ( Expression ) | #id ID Var-call-prime | #push_num NUM
Var-call-prime -> ( #start_call Args ) #end_call | Var-prime
Var-prime -> [ Expression ] #array_calc | EPSILON
Factor-prime -> ( #start_call Args ) #end_call | EPSILON
Factor-zegond -> ( Expression ) | #push_num NUM
Args -> Arg-list | EPSILON
Arg-list -> Expression Arg-list-prime
Arg-list-prime -> , #arg_input Expression Arg-list-prime | EPSILON #arg_input