diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-06-05 13:40:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-06-05 13:40:09 +0300 |
commit | 20e38a593d6bbe0a6d85eab83831ae6363d5cddb (patch) | |
tree | df47144b38a0d7fdb52d132697a6fdf285b72a28 /src | |
parent | 5158e36100a0483bbf8a37ad8dd32342f68bd7ea (diff) | |
download | paranucker-20e38a593d6bbe0a6d85eab83831ae6363d5cddb.tar.gz paranucker-20e38a593d6bbe0a6d85eab83831ae6363d5cddb.tar.bz2 paranucker-20e38a593d6bbe0a6d85eab83831ae6363d5cddb.tar.xz paranucker-20e38a593d6bbe0a6d85eab83831ae6363d5cddb.zip |
Add parsing node POINTER_TYPE.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/nodes/pointertypenode.h | 38 | ||||
-rw-r--r-- | src/parsers/generic.cpp | 8 | ||||
-rw-r--r-- | src/parsers/pointer_type.cpp | 44 |
4 files changed, 90 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index f5d1f36..f6c6efe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,6 +9,7 @@ SRC = nodes/base/cstnode.h \ nodes/identifiernode.h \ nodes/integercstnode.h \ nodes/parmdeclnode.h \ + nodes/pointertypernode.h \ nodes/resultdeclnode.h \ nodes/treelistnode.h \ nodes/typedeclnode.h \ @@ -20,6 +21,7 @@ SRC = nodes/base/cstnode.h \ parsers/identifier_node.cpp \ parsers/integer_cst.cpp \ parsers/parserincludes.h \ + parsers/pointer_type.cpp \ parsers/result_decl.cpp \ parsers/tree_list.cpp \ parsers/type_decl.cpp \ diff --git a/src/nodes/pointertypenode.h b/src/nodes/pointertypenode.h new file mode 100644 index 0000000..ef3ae20 --- /dev/null +++ b/src/nodes/pointertypenode.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2015 Andrei Karas + * + * This file is part of AstDumper. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef NODES_POINTERTYPENODE_H +#define NODES_POINTERTYPENODE_H + +#include "nodes/base/typenode.h" + +#include <string> + +struct PointerTypeNode : public TypeNode +{ + PointerTypeNode() : + TypeNode(), + nestedType(nullptr) + { + } + + TypeNode *nestedType; +}; + +#endif // NODES_POINTERTYPENODE_H diff --git a/src/parsers/generic.cpp b/src/parsers/generic.cpp index 1cf74b4..732f2f3 100644 --- a/src/parsers/generic.cpp +++ b/src/parsers/generic.cpp @@ -21,6 +21,7 @@ #include "nodes/functiondeclnode.h" #include "nodes/functiontypenode.h" +#include "nodes/pointertypenode.h" #include "nodes/voidtypenode.h" #include "nodes/typedeclnode.h" #include "nodes/identifiernode.h" @@ -29,10 +30,11 @@ #include "parsers/parserincludes.h" parserDefine(FunctionDecl); -parserDefine(FunctionType); parserDefine(ResultDecl); -parserDefine(VoidType); parserDefine(TypeDecl); +parserDefine(FunctionType); +parserDefine(PointerType); +parserDefine(VoidType); parserDefine(TreeList); parserDefine(Identifier); parserDefine(IntegerCst); @@ -81,6 +83,7 @@ Node *createParseNode(Node *parent, createNodeType(TYPE_DECL, TypeDeclNode); createNodeType(FUNCTION_TYPE, FunctionTypeNode); createNodeType(VOID_TYPE, VoidTypeNode); + createNodeType(POINTER_TYPE, PointerTypeNode); createNodeType(TREE_LIST, TreeListNode); createNodeType(IDENTIFIER_NODE, IdentifierNode); createNodeType(INTEGER_CST, IntegerCstNode); @@ -116,6 +119,7 @@ Node *createParseNode(Node *parent, parseNodeType(TYPE_DECL, TypeDecl); parseNodeType(FUNCTION_TYPE, FunctionType); parseNodeType(VOID_TYPE, VoidType); + parseNodeType(POINTER_TYPE, PointerType); parseNodeType(TREE_LIST, TreeList); parseNodeType(IDENTIFIER_NODE, Identifier); parseNodeType(INTEGER_CST, IntegerCst); diff --git a/src/parsers/pointer_type.cpp b/src/parsers/pointer_type.cpp new file mode 100644 index 0000000..681dfed --- /dev/null +++ b/src/parsers/pointer_type.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2015 Andrei Karas + * + * This file is part of AstDumper. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "parsers/parserincludes.h" + +parserDefine(PointerType); + +#include "parsers/base/type.h" + +#include "nodes/pointertypenode.h" + +namespace Generic +{ + +void parsePointerTypeNode(PointerTypeNode *node) +{ + fillType(node); + Log::log(node); + + fillTypeName(node); + fillTypeAttributes(node); + node->nestedType = static_cast<TypeNode*>(createParseNode( + node, + TREE_TYPE(node->gccNode), + "nested type")); +} + +} |