-
Notifications
You must be signed in to change notification settings - Fork 14
/
R_syntax.bnf
91 lines (91 loc) · 1.99 KB
/
R_syntax.bnf
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
translation_unit : stat_or_decl_list
;
stat_or_decl_list : stat_or_decl
| stat_or_decl_list stat_or_decl
;
stat_or_decl : stat
| external_decl ';'
;
external_decl : "extern" ID
| "extern" ID attribute_spec
| "extern" ID '=' NUMBER
| "extern" ID attribute_spec '=' NUMBER
;
stat : labeled_stat
| ';'
| '{' stat_or_decl_list '}'
| jump_stat
| selection_stat
| assignment_exp ';'
;
labeled_stat : ID ':' stat
;
jump_stat : "goto" ID ';'
| "break" ';'
| "continue" ';'
;
selection_stat : "if" conditional_exp stat
| "if" conditional_exp stat "else" stat
| "do" stat "while" conditional_exp ';'
| "while" conditional_exp stat
;
conditional_exp : '(' assignment_exp ')'
| '!' '(' assignment_exp ')'
;
assignment_exp : or_exp
| lvalue_exp '=' assignment_exp
;
or_exp : xor_exp
| or_exp '&' xor_exp
;
xor_exp : and_exp
| xor_exp '&' and_exp
;
and_exp : additive_exp
| and_exp '&' additive_exp
;
additive_exp : multiplicative_exp
| additive_exp '+' multiplicative_exp
| additive_exp '-' multiplicative_exp
;
multiplicative_exp : rvalue_exp
| multiplicative_exp '*' rvalue_exp
| multiplicative_exp '/' rvalue_exp
;
rvalue_exp : immediate_exp
| lvalue_exp
| ID '(' ')'
| ID '(' argument_exp_list ')'
| attribute_spec ID '(' ')'
| attribute_spec ID '(' argument_exp_list ')'
| '(' or_exp ')'
;
argument_exp_list : or_exp
| or_exp ',' argument_exp_list
;
lvalue_exp : '*' ID
| ID
| type_qualifier ID
;
type_qualifier : "const" | "volatile"
;
immediate_exp : NUMBER
| '+' NUMBER
| '-' NUMBER
| STRING
| '@' STRING
| '&' ID
| '{' initializer_list '}'
;
initializer_list : immediate_exp
| initializer_list ',' immediate_exp
;
attribute_spec : '[' '[' attribute_list ']' ']'
;
attribute_list : attribute
| attribute ',' attribute_list
;
attribute : "noreturn" | "stdcall" | "stack"
| "regparm" = NUMBER
| "stack" = NUMBER
;