summaryrefslogtreecommitdiff
path: root/src/parsers/generic.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-03 18:33:18 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-03 18:33:18 +0300
commit6cecc9730f99096c29c045c050a948254bc59dbb (patch)
tree99a20a203b15cae5b6641dea868034b3543b5cbc /src/parsers/generic.cpp
parent353973e99f0be7d685e98bbdd7a020c9cbd282e4 (diff)
downloadparanucker-6cecc9730f99096c29c045c050a948254bc59dbb.tar.gz
paranucker-6cecc9730f99096c29c045c050a948254bc59dbb.tar.bz2
paranucker-6cecc9730f99096c29c045c050a948254bc59dbb.tar.xz
paranucker-6cecc9730f99096c29c045c050a948254bc59dbb.zip
Improve a bit shared logic for create and parse nodes.
Diffstat (limited to 'src/parsers/generic.cpp')
-rw-r--r--src/parsers/generic.cpp48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/parsers/generic.cpp b/src/parsers/generic.cpp
index 2db51aa..4bb9a2a 100644
--- a/src/parsers/generic.cpp
+++ b/src/parsers/generic.cpp
@@ -33,7 +33,7 @@
namespace Generic
{
-Node *createEmptyNode(Node *parent, tree gccNode)
+Node *createParseNode(Node *parent, tree gccNode)
{
if (gccNode == NULL_TREE)
{
@@ -63,40 +63,30 @@ Node *createEmptyNode(Node *parent, tree gccNode)
node->gccNode = gccNode;
if (parent)
node->indent = parent->indent + 1;
- }
- return node;
-}
-
-void parseNode(Node *node)
-{
- if (!node || node->gccNode == NULL_TREE)
- {
- return;
- }
- switch (TREE_CODE(node->gccNode))
- {
- case FUNCTION_DECL:
- parseFunctionDeclNode(node);
- break;
- case FUNCTION_TYPE:
- parseFunctionTypeNode(node);
- break;
- case RESULT_DECL:
- parseResultDeclNode(node);
- break;
- default:
- Log::log(node, "Not supported node type: %s",
- get_tree_code_name(TREE_CODE(node->gccNode)));
- break;
+ switch (TREE_CODE(node->gccNode))
+ {
+ case FUNCTION_DECL:
+ parseFunctionDeclNode(node);
+ break;
+ case FUNCTION_TYPE:
+ parseFunctionTypeNode(node);
+ break;
+ case RESULT_DECL:
+ parseResultDeclNode(node);
+ break;
+ default:
+ Log::log(node, "Not supported node type: %s",
+ get_tree_code_name(TREE_CODE(node->gccNode)));
+ break;
+ }
}
+ return node;
}
void parseNodes(tree gccNode)
{
- //Node *rootNode = new Node;
- Node *node = createEmptyNode(nullptr, gccNode);
- parseNode(node);
+ createParseNode(nullptr, gccNode);
}
void fillType(Node *node)