summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-13 16:43:56 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-13 16:43:56 +0300
commit9eb5f9ddfdb7ae7c002ef4f53e7fe42956a68401 (patch)
tree82f0b394f522f51c8cda35132cdffe68099731bc
parent9217cb3fb59aa1890cdb36adbaffb0fa858a68d0 (diff)
downloadparanucker-9eb5f9ddfdb7ae7c002ef4f53e7fe42956a68401.tar.gz
paranucker-9eb5f9ddfdb7ae7c002ef4f53e7fe42956a68401.tar.bz2
paranucker-9eb5f9ddfdb7ae7c002ef4f53e7fe42956a68401.tar.xz
paranucker-9eb5f9ddfdb7ae7c002ef4f53e7fe42956a68401.zip
Add parsing node FOR_STMT.
-rw-r--r--src/Makefile.files4
-rw-r--r--src/includes/nodeincludes.h1
-rw-r--r--src/includes/nodeshandling.inc1
-rw-r--r--src/includes/parserdefines.inc1
-rw-r--r--src/nodes/stmt/for_stmt.h46
-rw-r--r--src/parsers/stmt/for_stmt.cpp57
6 files changed, 109 insertions, 1 deletions
diff --git a/src/Makefile.files b/src/Makefile.files
index e056089..b492029 100644
--- a/src/Makefile.files
+++ b/src/Makefile.files
@@ -213,4 +213,6 @@ SRC = analysis/analysis.cpp \
nodes/expr/roundmod_expr.h \
parsers/expr/roundmod_expr.cpp \
nodes/expr/negate_expr.h \
- parsers/expr/negate_expr.cpp \ No newline at end of file
+ parsers/expr/negate_expr.cpp \
+ nodes/stmt/for_stmt.h \
+ parsers/stmt/for_stmt.cpp \ No newline at end of file
diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h
index 2ebd342..3065288 100644
--- a/src/includes/nodeincludes.h
+++ b/src/includes/nodeincludes.h
@@ -86,3 +86,4 @@
#include "nodes/expr/ceilmod_expr.h"
#include "nodes/expr/roundmod_expr.h"
#include "nodes/expr/negate_expr.h"
+#include "nodes/stmt/for_stmt.h"
diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc
index e5904b0..e63cec2 100644
--- a/src/includes/nodeshandling.inc
+++ b/src/includes/nodeshandling.inc
@@ -85,3 +85,4 @@ handleNodeType(FLOOR_MOD_EXPR, FloorModExpr)
handleNodeType(CEIL_MOD_EXPR, CeilModExpr)
handleNodeType(ROUND_MOD_EXPR, RoundModExpr)
handleNodeType(NEGATE_EXPR, NegateExpr)
+handleNodeType(FOR_STMT, ForStmt)
diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc
index 33ea1a0..a6ae523 100644
--- a/src/includes/parserdefines.inc
+++ b/src/includes/parserdefines.inc
@@ -85,3 +85,4 @@ parserDefine(FloorModExpr);
parserDefine(CeilModExpr);
parserDefine(RoundModExpr);
parserDefine(NegateExpr);
+parserDefine(ForStmt);
diff --git a/src/nodes/stmt/for_stmt.h b/src/nodes/stmt/for_stmt.h
new file mode 100644
index 0000000..e2e47a9
--- /dev/null
+++ b/src/nodes/stmt/for_stmt.h
@@ -0,0 +1,46 @@
+/*
+ * 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_STMT_FORSTMTNODE_H
+#define NODES_STMT_FORSTMTNODE_H
+
+#include "nodes/base/stmt.h"
+
+#include "nodes/base/expr.h"
+
+#include <string>
+
+struct ForStmtNode : public StmtNode
+{
+ ForStmtNode() :
+ StmtNode(),
+ body(nullptr),
+ condition(nullptr),
+ expression(nullptr),
+ init(nullptr)
+ {
+ }
+
+ StmtNode *body;
+ ExprNode *condition;
+ ExprNode *expression;
+ StmtNode *init;
+};
+
+#endif // NODES_STMT_FORSTMTNODE_H
diff --git a/src/parsers/stmt/for_stmt.cpp b/src/parsers/stmt/for_stmt.cpp
new file mode 100644
index 0000000..ba6e18b
--- /dev/null
+++ b/src/parsers/stmt/for_stmt.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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 "includes/parserincludes.h"
+
+parserDefine(ForStmt);
+
+#include "parsers/base/stmt.h"
+
+#include "nodes/stmt/for_stmt.h"
+
+namespace Generic
+{
+
+void parseForStmtNode(ForStmtNode *node)
+{
+ fillType(node);
+ Log::dump(node);
+
+ node->init = static_cast<StmtNode*>(createParseNode(
+ node,
+ FOR_INIT_STMT(node->gccNode),
+ "init"));
+
+ node->expression = static_cast<ExprNode*>(createParseNode(
+ node,
+ FOR_EXPR(node->gccNode),
+ "expression"));
+
+ node->condition = static_cast<ExprNode*>(createParseNode(
+ node,
+ FOR_COND(node->gccNode),
+ "condition"));
+
+ node->body = static_cast<StmtNode*>(createParseNode(
+ node,
+ FOR_BODY(node->gccNode),
+ "body"));
+}
+
+}