-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction-rules.txt
More file actions
63 lines (63 loc) · 2.95 KB
/
action-rules.txt
File metadata and controls
63 lines (63 loc) · 2.95 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Program -> Declaration-list
Declaration-list -> Declaration Declaration-list
Declaration-list -> ''
Declaration -> Declaration-initial Declaration-prime
Declaration-initial -> Type-specifier #declaring_pid ID
Declaration-prime -> Fun-declaration-prime
Declaration-prime -> Var-declaration-prime
Var-declaration-prime -> #variable_declared ;
Var-declaration-prime -> [ #array_size NUM ] #array_declared ;
Fun-declaration-prime -> #function_start ( Params ) #function_params_end Compound-stmt #function_end
Type-specifier -> int #int_type
Type-specifier -> void #void_type
Params -> int #int_type #declaring_pid ID #push_param Param-prime Param-list
Params -> void
Param-list -> , #push_param Param Param-list
Param-list -> ''
Param -> Declaration-initial Param-prime
Param-prime -> [ ] #array_param #pop_int_type
Param-prime -> '' #scalar_param #pop_int_type
Compound-stmt -> #scope_begin { Declaration-list #variables_declared Statement-list } #scope_end
Statement-list -> Statement Statement-list
Statement-list -> ''
Statement -> Expression-stmt
Statement -> Compound-stmt
Statement -> Selection-stmt
Statement -> Iteration-stmt
Statement -> Return-stmt
Expression-stmt -> Expression ; #pop_expression -> pop one to remove the statement result from stack
Expression-stmt -> break #break ;
Expression-stmt -> ;
Selection-stmt -> if ( Expression ) #save_if Statement Else-stmt
Else-stmt -> endif #jpf
Else-stmt -> else #jpf_save Statement endif #jp
Iteration-stmt -> for (Expression #pop_expression; #for_condition_start Expression #for_condition_end; #for_step_begin Expression #pop_expression #for_step_end) #for_body_begin Statement #for_end
Return-stmt -> return Return-stmt-prime #jump_to_end
Return-stmt-prime -> ; | Expression #return_func ;
Expression -> Simple-expression-zegond | #pid ID B
B -> = Expression #assign | [ Expression ] #array H | Simple-expression-prime
H -> = Expression #assign | G D C
Simple-expression-zegond -> Additive-expression-zegond C
Simple-expression-prime -> Additive-expression-prime C
C -> Relop Additive-expression #calculate | ''
Relop -> #save_operator < | #save_operator ==
Additive-expression -> Term D
Additive-expression-prime -> Term-prime D
Additive-expression-zegond -> Term-zegond D
D -> Addop Term #calculate D | ''
Addop -> #save_operator + | #save_operator -
Term -> Signed-factor G
Term-prime -> Signed-factor-prime G
Term-zegond -> Signed-factor-zegond G
G -> #save_operator * Signed-factor #calculate G | ''
Signed-factor -> + Factor | - Factor #negate | Factor
Signed-factor-prime -> Factor-prime
Signed-factor-zegond -> + Factor | - Factor #negate | Factor-zegond
Factor -> ( Expression ) | #pid ID Var-call-prime | #immediate NUM
Var-call-prime -> #args_begin ( Args ) #call | Var-prime
Var-prime -> [ Expression ] #array | ''
Factor-prime -> #args_begin ( Args ) #call | ''
Factor-zegond -> ( Expression ) | #immediate NUM
Args -> Arg-list | ''
Arg-list -> Expression #push_arg Arg-list-prime
Arg-list-prime -> , Expression #push_arg Arg-list-prime | ''