From 37cf922007f11b2c10f4f6691bf35748847db27d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 16 Jun 2015 22:09:25 +0300 Subject: Add parsing node DO_STMT. --- src/Makefile.files | 4 +++- src/includes/nodeincludes.h | 1 + src/includes/nodeshandling.inc | 1 + src/includes/parserdefines.inc | 1 + src/nodes/stmt/do_stmt.h | 40 ++++++++++++++++++++++++++++++++ src/parsers/stmt/do_stmt.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/nodes/stmt/do_stmt.h create mode 100644 src/parsers/stmt/do_stmt.cpp diff --git a/src/Makefile.files b/src/Makefile.files index fe46759..7dc324b 100644 --- a/src/Makefile.files +++ b/src/Makefile.files @@ -272,4 +272,6 @@ SRC = analysis/analysis.cpp \ nodes/ref/bitfield_ref.h \ parsers/ref/bitfield_ref.cpp \ nodes/stmt/continue_stmt.h \ - parsers/stmt/continue_stmt.cpp \ No newline at end of file + parsers/stmt/continue_stmt.cpp \ + nodes/stmt/do_stmt.h \ + parsers/stmt/do_stmt.cpp \ No newline at end of file diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h index 7885bc0..174de61 100644 --- a/src/includes/nodeincludes.h +++ b/src/includes/nodeincludes.h @@ -114,3 +114,4 @@ #include "nodes/ref/array_ref.h" #include "nodes/ref/bitfield_ref.h" #include "nodes/stmt/continue_stmt.h" +#include "nodes/stmt/do_stmt.h" diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc index c29c718..ec67fde 100644 --- a/src/includes/nodeshandling.inc +++ b/src/includes/nodeshandling.inc @@ -113,3 +113,4 @@ handleNodeType(THROW_EXPR, ThrowExpr) handleNodeType(ARRAY_REF, ArrayRef) handleNodeType(BIT_FIELD_REF, BitFieldRef) handleNodeType(CONTINUE_STMT, ContinueStmt) +handleNodeType(DO_STMT, DoStmt) diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc index 4aecfd8..95ae0a7 100644 --- a/src/includes/parserdefines.inc +++ b/src/includes/parserdefines.inc @@ -113,3 +113,4 @@ parserDefine(ThrowExpr); parserDefine(ArrayRef); parserDefine(BitFieldRef); parserDefine(ContinueStmt); +parserDefine(DoStmt); diff --git a/src/nodes/stmt/do_stmt.h b/src/nodes/stmt/do_stmt.h new file mode 100644 index 0000000..2e98266 --- /dev/null +++ b/src/nodes/stmt/do_stmt.h @@ -0,0 +1,40 @@ +/* + * 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 . + */ + +#ifndef NODES_STMT_DOSTMTNODE_H +#define NODES_STMT_DOSTMTNODE_H + +#include "nodes/base/stmt.h" + +#include + +struct DoStmtNode : public StmtNode +{ + DoStmtNode() : + StmtNode(), + body(nullptr), + condition(nullptr) + { + } + + Node *body; + ExprNode *condition; +}; + +#endif // NODES_STMT_DOSTMTNODE_H diff --git a/src/parsers/stmt/do_stmt.cpp b/src/parsers/stmt/do_stmt.cpp new file mode 100644 index 0000000..1b485bc --- /dev/null +++ b/src/parsers/stmt/do_stmt.cpp @@ -0,0 +1,52 @@ +/* + * 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 . + */ + +#include "includes/parserincludes.h" + +parserDefine(DoStmt); + + +#include "parsers/base/expr.h" +#include "parsers/base/stmt.h" + +#include "nodes/base/expr.h" + +#include "nodes/stmt/do_stmt.h" + +namespace Generic +{ + +void parseDoStmtNode(DoStmtNode *node) +{ + fillType(node); + fillExprLocation(node); + Log::dump(node); + + node->condition = static_cast(createParseNode( + node, + DO_COND(node->gccNode), + "condition")); + + node->body = createParseNode( + node, + DO_BODY(node->gccNode), + "body"); +} + +} -- cgit v1.2.3-60-g2f50