Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: de45b9fb328ab0199e4cf32b630c4f5cd5f0edbc (plain) (blame)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
-----------------------------------------------------------------------------------
-- Copyright (c) 2008, 2009 IBM Corporation and others.
-- All rights reserved. This program and the accompanying materials
-- are made available under the terms of the Eclipse Public License v1.0
-- which accompanies this distribution, and is available at
-- http://www.eclipse.org/legal/epl-v10.html
--
-- Contributors:
--     IBM Corporation - initial API and implementation
-----------------------------------------------------------------------------------


--  These are additional rules that allow for parsing of GNU extensions.
--  This file is intended to be mixed-in with C99Parser.g or GPPParser.g


$Terminals
	-- additional GCC only tokens as defined in IGCCToken

	typeof
	__alignof__
	__attribute__
	__declspec
	MAX
	MIN
	
	MAX ::= '>?'
	MIN ::= '<?'
	
$End



$Headers
/.
	private $gnu_action_class gnuAction;
./
$End

$Define

	$gnu_action_class /.  ./

	$action_initializations /.
	
		gnuAction = new $gnu_action_class (this, tu, astStack, $node_factory_create_expression);
		gnuAction.setParserOptions(options);
		gnuAction.setBaseAction(action);
	./
	
$End

$Rules

------------------------------------------------------------------------------------
-- Support for __attribute__ and __declspec
------------------------------------------------------------------------------------

attribute_or_decl_specifier
    ::= attribute_specifier
      | decl_specifier
      | asm_label

attribute_or_decl_specifier_seq
    ::= attribute_or_decl_specifier
      | attribute_or_decl_specifier_seq attribute_or_decl_specifier



attribute_specifier
    ::= '__attribute__' '(' '(' attribute_list ')' ')'
      | '__attribute__' '(' ')'
    
attribute_list
    ::= attribute
      | attribute_list ',' attribute

attribute
    ::= word
      | word '(' attribute_parameter_list ')'
      | $empty
      
word
    ::= 'identifier'
      | 'const'

attribute_parameter_list
    ::= attribute_parameter
      | attribute_parameter_list ',' attribute_parameter

attribute_parameter
    ::= assignment_expression
          /. $Build  consumeIgnore(); $EndBuild ./
      | $empty



decl_specifier
    ::= '__declspec' '(' extended_decl_modifier_seq ')'
      | '__declspec' '(' ')'    
      
extended_decl_modifier_seq
    ::= extended_decl_modifier
      | extended_decl_modifier_seq extended_decl_modifier
    
extended_decl_modifier
    ::= 'identifier'
      | 'identifier' '(' ')'
      | 'identifier' '(' 'identifier' ')'


------------------------------------------------------------------------------------
-- Other stuff
------------------------------------------------------------------------------------

asm_label
    ::= 'asm' '(' 'stringlit' ')'


extended_asm_declaration
    ::= 'asm' volatile_opt '(' extended_asm_param_seq ')' ';'
           /. $BeginAction  gnuAction.consumeDeclarationASM(); $EndAction ./

volatile_opt ::= 'volatile' | $empty

extended_asm_param_seq
    ::= extended_asm_param_with_operand
      | extended_asm_param_seq ':' extended_asm_param_with_operand

extended_asm_param_with_operand
    ::= extended_asm_param
      | extended_asm_param ',' extended_asm_param
      | $empty
      
extended_asm_param
    ::= 'stringlit'
      | 'stringlit' '(' 'identifier' ')'
      | 'stringlit' '(' '*' 'identifier' ')'



unary_expression
    ::= '__alignof__' unary_expression
          /. $Build  consumeExpressionUnaryOperator(IASTUnaryExpression.op_alignOf);  $EndBuild ./
      | '__alignof__' '(' type_id ')'
          /. $Build  consumeExpressionTypeId(IASTTypeIdExpression.op_alignof);  $EndBuild ./  
      | 'typeof' unary_expression
          /. $Build  consumeExpressionUnaryOperator(IASTUnaryExpression.op_typeof);  $EndBuild ./
      | 'typeof' '(' type_id ')'
          /. $Build  consumeExpressionTypeId(IASTTypeIdExpression.op_typeof);  $EndBuild ./  
          
          
relational_expression
    ::= relational_expression '>?' shift_expression
          /. $Build  consumeExpressionBinaryOperator(IASTBinaryExpression.op_max);  $EndBuild ./
      | relational_expression '<?' shift_expression
          /. $Build  consumeExpressionBinaryOperator(IASTBinaryExpression.op_min);  $EndBuild ./
          
          
          
typeof_type_specifier
      ::= 'typeof' unary_expression
        
        
typeof_declaration_specifiers
    ::= typeof_type_specifier
      | no_type_declaration_specifiers  typeof_type_specifier
      | typeof_declaration_specifiers no_type_declaration_specifier
      
      
declaration_specifiers
    ::= <openscope-ast> typeof_declaration_specifiers
          /. $BeginAction  gnuAction.consumeDeclarationSpecifiersTypeof();  $EndAction ./
        
$End

Back to the top