Skip to content

Commit b60bb87

Browse files
committed
Makefile for parser
1 parent a1ddf7f commit b60bb87

8 files changed

Lines changed: 31 additions & 86 deletions

File tree

Makefile.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ $(BUILD_DIR)/%.o : %.cpp | create-folders
5050
$(CC) $(INCLUDES) $(CXXFLAGS) -MM -MT $@ -MF $(patsubst %.o,%.d,$@) $<
5151
$(CC) $(INCLUDES) -c $< -o $@ $(CXXFLAGS)
5252

53-
$(LIB_SBGRAPH): create-folders $(UTIL_OBJ) $(SBG_OBJ) $(PARSER_OBJ) $(EVAL_OBJ)
54-
$(AR) rcs $(LIB_SBGRAPH) $(UTIL_OBJ) $(SBG_OBJ) $(PARSER_OBJ) $(EVAL_OBJ)
53+
LIB_SRC := $(shell find ast parser sbg eval util -type f -name "*.cpp")
54+
LIB_OBJ = $(addprefix $(BUILD_DIR)/, $(LIB_SRC:.cpp=.o))
55+
56+
$(LIB_SBGRAPH): create-folders $(LIB_OBJ)
57+
$(AR) rcs $(LIB_SBGRAPH) $(LIB_OBJ)
5558

5659
#///////////////////////////////////////////////////////////////////////////////
5760
# Library Installation ---------------------------------------------------------
@@ -92,7 +95,7 @@ ifeq ("$(wildcard $(3RD_PARTY_DIR)/gtest/usr/lib)","")
9295
endif
9396

9497
test: lib-gtest
95-
@cd $(TEST_DIR) && make
98+
@cd $(TEST_DIR) && ./compile_run_tests.sh
9699

97100
#///////////////////////////////////////////////////////////////////////////////
98101
# Documentation ----------------------------------------------------------------

eval/visitors/eval_expr.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ auto diff_visitor_ = Overload{
184184
};
185185

186186
auto empty_visitor_ = Overload {
187-
[](LIB::Interval a) { return a.isEmpty(); },
188-
[](LIB::MultiDimInter a) { return a.isEmpty(); },
189-
[](LIB::Set a) { return a.isEmpty(); },
187+
[](LIB::Interval a) { return Boolean(a.isEmpty()); },
188+
[](LIB::MultiDimInter a) { return Boolean(a.isEmpty()); },
189+
[](LIB::Set a) { return Boolean(a.isEmpty()); },
190190
[](auto a) {
191191
Util::ERROR("empty_visitor_: wrong argument ", a, " for isEmpty\n");
192-
return false;
192+
return Boolean();
193193
}
194194
};
195195

@@ -556,25 +556,20 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const
556556
case Eval::Func::empty:
557557
if (eval_args.size() == 1) {
558558
arity_ok = true;
559-
560-
bool res = std::visit(empty_visitor_, eval_args[0]);
561-
return LIB::MD_NAT(res);
559+
return std::visit(empty_visitor_, eval_args[0]);
562560
}
563561
break;
564562

565563
case Eval::Func::min:
566564
if (eval_args.size() == 1) {
567565
arity_ok = true;
568-
569-
LIB::MD_NAT result = std::visit(min_visitor_, eval_args[0]);
570-
return result;
566+
return std::visit(min_visitor_, eval_args[0]);
571567
}
572568
break;
573569

574570
case Eval::Func::max:
575571
if (eval_args.size() == 1) {
576572
arity_ok = true;
577-
578573
return std::visit(max_visitor_, eval_args[0]);
579574
}
580575
break;

parser/expr_def.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#ifndef EXPR_DEF_PARSER_HPP
2121
#define EXPR_DEF_PARSER_HPP
2222

23-
#include <boost/phoenix.hpp>
23+
#include <boost/phoenix/core.hpp>
24+
#include <boost/phoenix/operator.hpp>
25+
#include <boost/phoenix/object.hpp>
2426

2527
#include "ast/expr.hpp"
2628
#include "sbg/rational.hpp"

parser/sbg_program_def.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#ifndef PROGRAM_DEF_PARSER_HPP
2121
#define PROGRAM_DEF_PARSER_HPP
2222

23-
#include <boost/phoenix.hpp>
23+
#include <boost/phoenix/core.hpp>
24+
#include <boost/phoenix/operator.hpp>
25+
#include <boost/phoenix/object.hpp>
2426

2527
#include "ast/sbg_program.hpp"
2628

parser/statement_def.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
#ifndef STATEMENT_DEF_PARSER_HPP
2121
#define STATEMENT_DEF_PARSER_HPP
2222

23-
#include <boost/phoenix.hpp>
23+
#include <boost/phoenix/stl/container.hpp>
24+
#include <boost/phoenix/core.hpp>
25+
#include <boost/phoenix/operator.hpp>
26+
#include <boost/phoenix/object.hpp>
2427

2528
#include "ast/statement.hpp"
2629

test/parser/Makefile

Lines changed: 0 additions & 52 deletions
This file was deleted.

test/parser/compile_and_run.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/parser/parser_test.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,24 @@ TEST_P(ParserTests, Parser)
3434
{
3535
const std::string NAME = GetParam();
3636
std::cout << "Testing program: " << NAME << std::endl;
37-
const std::string PARSER_CMD = "./compile_and_run.sh " + NAME;
38-
const std::string RESULT_FILE = "./test_data/" + NAME + "/" + NAME + ".passed";
39-
const std::string TEST_CMD = "./results.sh " + NAME;
4037

38+
const std::string TEST_DIR = "./test_data/" + NAME;
39+
const std::string DIR_CMD = "mkdir -p " + TEST_DIR;
40+
std::system(DIR_CMD.c_str());
41+
const std::string PARSER_CMD = "../../bin/sbg-parser -f ../" + NAME
42+
+ ".test > " + TEST_DIR + "/SBG.log 2>&1";
4143
std::system(PARSER_CMD.c_str());
44+
const std::string TEST_CMD = "./results.sh " + NAME;
4245
std::system(TEST_CMD.c_str());
4346

47+
const std::string RESULT_FILE = "./test_data/" + NAME + "/" + NAME + ".passed";
4448
std::ifstream result(RESULT_FILE.c_str());
4549
EXPECT_TRUE(result.good());
4650
}
4751

4852
const char* parser_program[] = {"arithmetic", "interval", "set", "lexp", "map"};
4953

50-
INSTANTIATE_TEST_SUITE_P(ParserInst, ParserTests, testing::ValuesIn(parser_program));
54+
INSTANTIATE_TEST_SUITE_P(ParserInst, ParserTests
55+
, testing::ValuesIn(parser_program));
5156

5257
/// @}

0 commit comments

Comments
 (0)