127
127
# FOR SEARCHING AFTER /* .. */.
128
128
PAIRED_COMMENT_RE = re.compile(r"(/[*].*?[*]/)")
130
# Fixed macro definitions
131
# TODO: Make these configurable at runtime, perhaps by parsing an override file?
133
"BOOST_PP_CAT" : [ ( ['a', 'b'], "a ## b" ) ],
134
"BOOST_PP_STRINGIZE" : [ ( ['text'], "#text" ) ],
135
"BOOST_PP_ITERATE": [ ( [], "BOOST_PP_FILENAME_1" ), ( [], "BOOST_PP_FILENAME_2" ), \
136
( [], "BOOST_PP_TUPLE_ELEM_3_2(BOOST_PP_TUPLE_ELEM_2_1(BOOST_PP_ITERATION_PARAMS_1))") ],
137
"AUX778076_PREPROCESSED_HEADER" : [ "BOOST_MPL_CFG_COMPILER_DIR/BOOST_MPL_PREPROCESSED_HEADER" ],
138
"AUX778076_INCLUDE_STRING" : [ "" ],
139
"BOOST_MPL_CFG_COMPILER_DIR" : [ "gcc" ],
140
"BOOST_COMPILER_CONFIG" : [ "boost/config/compiler/gcc.hpp" ],
141
"BOOST_STDLIB_CONFIG" : [ "boost/config/stdlib/libstdcpp3.hpp"],
142
"BOOST_PLATFORM_CONFIG" : [ "boost/config/platform/macos.hpp" ]
145
130
def InsertMacroDefInTable(lhs, rhs, symbol_table, callback_function):
146
131
"""Insert the definition of a pair (lhs, rhs) into symbol table.
155
140
if m_expr.end(0) != len(lhs):
156
141
raise NotCoveredError(
157
142
"Unexpected macro definition with LHS: '%s'." % lhs)
158
if m_expr.group('symbol') in OVERRIDE_MACROS:
143
# Calculate the definition df, either
144
# - a pair ([arg_1, .., arg_n], rhs) where arg_i is the
145
# i'th formal parameter (function-like macro definition), or
146
# - just a symbol (object-like macro definition)
147
if m_expr.group('args') != None: # perhaps ''
148
# A function-like macro definition.
149
# Construct pair (list of formal parameters, rhs).
150
args = [param.strip() for param in m_expr.group('args').split(',')]
152
# lhs is adjusted to be just the 'function' name
159
153
lhs = m_expr.group('symbol')
160
if lhs not in symbol_table:
161
symbol_table[lhs] = OVERRIDE_MACROS[lhs]
162
callback_function(lhs)
154
else: # m_expr.group('args')
155
# An object-like macro definition
156
assert m_expr.group('symbol') == lhs
158
if lhs not in symbol_table:
159
symbol_table[lhs] = [df]
164
# Calculate the definition df, either
165
# - a pair ([arg_1, .., arg_n], rhs) where arg_i is the
166
# i'th formal parameter (function-like macro definition), or
167
# - just a symbol (object-like macro definition)
168
if m_expr.group('args') != None: # perhaps ''
169
# A function-like macro definition.
170
# Construct pair (list of formal parameters, rhs).
171
args = [param.strip() for param in m_expr.group('args').split(',')]
173
# lhs is adjusted to be just the 'function' name
174
lhs = m_expr.group('symbol')
175
else: # m_expr.group('args')
176
# An object-like macro definition
177
assert m_expr.group('symbol') == lhs
179
if lhs not in symbol_table:
180
symbol_table[lhs] = [df]
182
symbol_table[lhs].append(df)
183
callback_function(lhs)
161
symbol_table[lhs].append(df)
162
callback_function(lhs)
186
165
class ParseFile(object):