-
Notifications
You must be signed in to change notification settings - Fork 0
/
c-minus_001.txt
45 lines (45 loc) · 1.85 KB
/
c-minus_001.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
Program -> Declaration_list $
Declaration_list -> Declaration Declaration_list | epsilon
Declaration -> Declaration_initial Declaration_prime
Declaration_initial -> Type_specifier ID
Declaration_prime -> Fun_declaration_prime | Var_declaration_prime
Var_declaration_prime -> ; | [ NUM ] ;
Fun_declaration_prime -> ( Params ) Compound_stmt
Type_specifier -> int | void
Params -> int ID Param_prime Param_list | void
Param_list -> , Param Param_list | epsilon
Param -> Declaration_initial Param_prime
Param_prime -> [ ] | epsilon
Compound_stmt -> { Declaration_list Statement_list }
Statement_list -> Statement Statement_list | epsilon
Statement -> Expression_stmt | Compound_stmt | Selection_stmt | Iteration_stmt | Return_stmt
Expression_stmt -> Expression ; | break ; | ;
Selection_stmt -> if ( Expression ) Statement Else_stmt
Else_stmt -> endif | else Statement endif
Iteration_stmt -> repeat Statement until ( Expression )
Return_stmt -> return Return_stmt_prime
Return_stmt_prime -> ; | Expression ;
Expression -> Simple_expression_zegond | ID B
B -> = Expression | [ Expression ] H | Simple_expression_prime
H -> = Expression | G D C
Simple_expression_zegond -> Additive_expression_zegond C
Simple_expression_prime -> Additive_expression_prime C
C -> Relop Additive_expression | epsilon
Relop -> < | ==
Additive_expression -> Term D
Additive_expression_prime -> Term_prime D
Additive_expression_zegond -> Term_zegond D
D -> Addop Term D | epsilon
Addop -> + | _
Term -> Factor G
Term_prime -> Factor_prime G
Term_zegond -> Factor_zegond G
G -> * Factor G | epsilon
Factor -> ( Expression ) | ID Var_call_prime | NUM
Var_call_prime -> ( Args ) | Var_prime
Var_prime -> [ Expression ] | epsilon
Factor_prime -> ( Args ) | epsilon
Factor_zegond -> ( Expression ) | NUM
Args -> Arg_list | epsilon
Arg_list -> Expression Arg_list_prime
Arg_list_prime -> , Expression Arg_list_prime | epsilon