File src/srcml/cxx/SrcmlCxxLanguage.cpp changed (mode: 100644) (index 54f3afb..b0384c3) |
... |
... |
static void postProcessParameterList(PNode *node, TreeBuilder &tb, |
41 |
41 |
static bool breakLeaf(PNode *node, TreeBuilder &tb, |
static bool breakLeaf(PNode *node, TreeBuilder &tb, |
42 |
42 |
const std::string &contents, char left, char right, |
const std::string &contents, char left, char right, |
43 |
43 |
SrcmlCxxSType newChild); |
SrcmlCxxSType newChild); |
|
44 |
|
static void takeWord(PNode *node, const PNode *of, int len); |
|
45 |
|
static void skipWord(PNode *node, const PNode *of, int len, |
|
46 |
|
const std::string &contents); |
44 |
47 |
static void dropLeadingWS(PNode *node, const std::string &contents); |
static void dropLeadingWS(PNode *node, const std::string &contents); |
45 |
48 |
static void postProcessConditional(PNode *node, TreeBuilder &tb, |
static void postProcessConditional(PNode *node, TreeBuilder &tb, |
46 |
49 |
const std::string &contents); |
const std::string &contents); |
|
... |
... |
postProcessIfStmt(PNode *node, TreeBuilder &tb, const std::string &contents) |
281 |
284 |
elseKw->stype = +SrcmlCxxSType::Separator; |
elseKw->stype = +SrcmlCxxSType::Separator; |
282 |
285 |
elseKw->value.token = static_cast<int>(Type::Keywords); |
elseKw->value.token = static_cast<int>(Type::Keywords); |
283 |
286 |
// Take "else" part. |
// Take "else" part. |
284 |
|
elseKw->value.from = elseIfKw->value.from; |
|
285 |
|
elseKw->value.len = 4; |
|
286 |
|
elseKw->line = elseIfKw->line; |
|
287 |
|
elseKw->col = elseIfKw->col; |
|
|
287 |
|
takeWord(elseKw, elseIfKw, 4); |
288 |
288 |
|
|
289 |
289 |
// Drop "else" prefix and whitespace that follows it. |
// Drop "else" prefix and whitespace that follows it. |
290 |
290 |
elseIfKw->value.token = static_cast<int>(Type::Keywords); |
elseIfKw->value.token = static_cast<int>(Type::Keywords); |
291 |
|
elseIfKw->value.from += 4; |
|
292 |
|
elseIfKw->value.len -= 4; |
|
293 |
|
elseIfKw->col += 4; |
|
294 |
|
dropLeadingWS(elseIfKw, contents); |
|
|
291 |
|
skipWord(elseIfKw, elseIfKw, 4, contents); |
295 |
292 |
|
|
296 |
293 |
PNode *newNode = tb.addNode(); |
PNode *newNode = tb.addNode(); |
297 |
294 |
newNode->stype = +SrcmlCxxSType::Elseif; |
newNode->stype = +SrcmlCxxSType::Elseif; |
|
... |
... |
breakLeaf(PNode *node, TreeBuilder &tb, const std::string &contents, |
382 |
379 |
|
|
383 |
380 |
PNode *left = tb.addNode(); |
PNode *left = tb.addNode(); |
384 |
381 |
left->stype = +SrcmlCxxSType::Separator; |
left->stype = +SrcmlCxxSType::Separator; |
385 |
|
left->value.from = child->value.from; |
|
386 |
|
left->value.len = 1; |
|
387 |
|
left->line = child->line; |
|
388 |
|
left->col = child->col; |
|
389 |
382 |
left->value.token = static_cast<int>(Type::LeftBrackets); |
left->value.token = static_cast<int>(Type::LeftBrackets); |
|
383 |
|
takeWord(left, child, 1); |
390 |
384 |
|
|
391 |
385 |
PNode *right = tb.addNode(); |
PNode *right = tb.addNode(); |
392 |
386 |
right->stype = +SrcmlCxxSType::Separator; |
right->stype = +SrcmlCxxSType::Separator; |
393 |
|
right->value.from = child->value.from + 1; |
|
394 |
|
right->value.len = child->value.len - 1; |
|
395 |
|
right->line = child->line; |
|
396 |
|
right->col = child->col + 1; |
|
397 |
387 |
right->value.token = static_cast<int>(Type::RightBrackets); |
right->value.token = static_cast<int>(Type::RightBrackets); |
398 |
|
dropLeadingWS(right, contents); |
|
|
388 |
|
skipWord(right, child, 1, contents); |
399 |
389 |
|
|
400 |
390 |
if (newChild == SrcmlCxxSType::None) { |
if (newChild == SrcmlCxxSType::None) { |
401 |
391 |
node->children.assign({ left, right }); |
node->children.assign({ left, right }); |
|
... |
... |
breakLeaf(PNode *node, TreeBuilder &tb, const std::string &contents, |
410 |
400 |
return false; |
return false; |
411 |
401 |
} |
} |
412 |
402 |
|
|
|
403 |
|
// Sets node label to prefix of different node's label. |
|
404 |
|
static void |
|
405 |
|
takeWord(PNode *node, const PNode *of, int len) |
|
406 |
|
{ |
|
407 |
|
assert(static_cast<int>(of->value.len) > len && |
|
408 |
|
"Word length is too large."); |
|
409 |
|
|
|
410 |
|
node->value.from = of->value.from; |
|
411 |
|
node->value.len = len; |
|
412 |
|
node->line = of->line; |
|
413 |
|
node->col = of->col; |
|
414 |
|
} |
|
415 |
|
|
|
416 |
|
// Sets node label to label of a different node after dropping prefix from it. |
|
417 |
|
static void |
|
418 |
|
skipWord(PNode *node, const PNode *of, int len, const std::string &contents) |
|
419 |
|
{ |
|
420 |
|
assert(static_cast<int>(of->value.len) > len && |
|
421 |
|
"Word length is too large."); |
|
422 |
|
|
|
423 |
|
node->value.from = of->value.from + len; |
|
424 |
|
node->value.len = of->value.len - len; |
|
425 |
|
node->line = of->line; |
|
426 |
|
node->col = of->col + len; |
|
427 |
|
|
|
428 |
|
dropLeadingWS(node, contents); |
|
429 |
|
} |
|
430 |
|
|
413 |
431 |
// Corrects node data to exclude leading whitespace. |
// Corrects node data to exclude leading whitespace. |
414 |
432 |
static void |
static void |
415 |
433 |
dropLeadingWS(PNode *node, const std::string &contents) |
dropLeadingWS(PNode *node, const std::string &contents) |