File src/srcml/cxx/SrcmlCxxLanguage.cpp changed (mode: 100644) (index 36c38e3..5203628) |
... |
... |
static void postProcessBlock(PNode *node, TreeBuilder &tb, |
38 |
38 |
static void postProcessParameterList(PNode *node, TreeBuilder &tb, |
static void postProcessParameterList(PNode *node, TreeBuilder &tb, |
39 |
39 |
const std::string &contents); |
const std::string &contents); |
40 |
40 |
static bool breakLeaf(PNode *node, TreeBuilder &tb, |
static bool breakLeaf(PNode *node, TreeBuilder &tb, |
41 |
|
const std::string &contents, char left, char right); |
|
|
41 |
|
const std::string &contents, char left, char right, |
|
42 |
|
SrcmlCxxSType newChild); |
42 |
43 |
static void dropLeadingWS(PNode *node, const std::string &contents); |
static void dropLeadingWS(PNode *node, const std::string &contents); |
43 |
44 |
static void postProcessConditional(PNode *node, TreeBuilder &tb, |
static void postProcessConditional(PNode *node, TreeBuilder &tb, |
44 |
45 |
const std::string &contents); |
const std::string &contents); |
|
... |
... |
postProcessBlock(PNode *node, TreeBuilder &tb, const std::string &contents) |
266 |
267 |
} |
} |
267 |
268 |
|
|
268 |
269 |
// Children: `{}` (with any whitespace in between). |
// Children: `{}` (with any whitespace in between). |
269 |
|
if (breakLeaf(node, tb, contents, '{', '}')) { |
|
|
270 |
|
if (breakLeaf(node, tb, contents, '{', '}', SrcmlCxxSType::Statements)) { |
270 |
271 |
return; |
return; |
271 |
272 |
} |
} |
272 |
273 |
|
|
|
... |
... |
postProcessParameterList(PNode *node, TreeBuilder &tb, |
284 |
285 |
const std::string &contents) |
const std::string &contents) |
285 |
286 |
{ |
{ |
286 |
287 |
// Children: `()` (with any whitespace in between). |
// Children: `()` (with any whitespace in between). |
287 |
|
if (breakLeaf(node, tb, contents, '(', ')')) { |
|
|
288 |
|
if (breakLeaf(node, tb, contents, '(', ')', SrcmlCxxSType::None)) { |
288 |
289 |
return; |
return; |
289 |
290 |
} |
} |
290 |
291 |
} |
} |
|
... |
... |
postProcessParameterList(PNode *node, TreeBuilder &tb, |
293 |
294 |
// rewritten. |
// rewritten. |
294 |
295 |
static bool |
static bool |
295 |
296 |
breakLeaf(PNode *node, TreeBuilder &tb, const std::string &contents, |
breakLeaf(PNode *node, TreeBuilder &tb, const std::string &contents, |
296 |
|
char left, char right) |
|
|
297 |
|
char left, char right, SrcmlCxxSType newChild) |
297 |
298 |
{ |
{ |
298 |
299 |
// Children: `<left><right>` (with any whitespace in between). |
// Children: `<left><right>` (with any whitespace in between). |
299 |
300 |
if (node->children.size() == 1 && |
if (node->children.size() == 1 && |
|
... |
... |
breakLeaf(PNode *node, TreeBuilder &tb, const std::string &contents, |
319 |
320 |
right->value.token = static_cast<int>(Type::RightBrackets); |
right->value.token = static_cast<int>(Type::RightBrackets); |
320 |
321 |
dropLeadingWS(right, contents); |
dropLeadingWS(right, contents); |
321 |
322 |
|
|
322 |
|
PNode *stmts = tb.addNode(); |
|
323 |
|
stmts->stype = +SrcmlCxxSType::Statements; |
|
|
323 |
|
if (newChild == SrcmlCxxSType::None) { |
|
324 |
|
node->children.assign({ left, right }); |
|
325 |
|
} else { |
|
326 |
|
PNode *stmts = tb.addNode(); |
|
327 |
|
stmts->stype = +newChild; |
324 |
328 |
|
|
325 |
|
node->children.assign({ left, stmts, right }); |
|
|
329 |
|
node->children.assign({ left, stmts, right }); |
|
330 |
|
} |
326 |
331 |
return true; |
return true; |
327 |
332 |
} |
} |
328 |
333 |
return false; |
return false; |