Skip to content

Commit

Permalink
Merge pull request #2 from sillydan1/patch/actions
Browse files Browse the repository at this point in the history
Fix for GitHub Actions and cross-platform compilation issues
  • Loading branch information
sillydan1 authored Mar 5, 2022
2 parents 51d6efb + 59ba50b commit 9b2f35b
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: CMake Pipeline
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

env:
BUILD_TYPE: Release
Expand Down Expand Up @@ -34,12 +34,12 @@ jobs:
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -j$(nproc)
run: cmake --build . --config $BUILD_TYPE -j$(nproc) --target expr
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: library
path: ${{ github.workspace }}/build/expr
path: ${{ github.workspace }}/build/libexpr.so
build-windows:
if: ${{ github.event.pull_request.draft == false }}
name: Build For MS Windows Systems
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include_directories(
include
src
)
add_library(${PROJECT_NAME}
add_library(${PROJECT_NAME} SHARED
${BISON_expr_parser_OUTPUTS}
${FLEX_expr_scanner_OUTPUTS}
src/parser/driver.cpp
Expand Down
7 changes: 4 additions & 3 deletions include/operations/boolean.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
symbol_value_t and_(const symbol_value_t& a, const symbol_value_t& b);
symbol_value_t or_(const symbol_value_t& a, const symbol_value_t& b);
symbol_value_t not_(const symbol_value_t& a);
symbol_value_t operator&&(const symbol_value_t& a, const symbol_value_t& b);
symbol_value_t operator||(const symbol_value_t& a, const symbol_value_t& b);
symbol_value_t operator!(const symbol_value_t& a);
// TODO: These operators are ambiguous with symbol_value_t && std::false_type / std::true_type for some reason.
//symbol_value_t operator&&(const symbol_value_t& a, const symbol_value_t& b);
//symbol_value_t operator||(const symbol_value_t& a, const symbol_value_t& b);
//symbol_value_t operator!(const symbol_value_t& a);
#endif //EXPR_BOOLEAN_H
6 changes: 4 additions & 2 deletions src/operations/add.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "operations/add.h"
#include "util.h"
#include "operations/util.h"
#include <sstream>

template<typename T1, typename T2>
auto t_add(const T1&, const T2&) {
throw std::domain_error((std::ostringstream{} << "Unable to add type " << typeid(T1).name() << " and " << typeid(T2).name()).str());
std::ostringstream ss{};
ss << "Unable to add type " << typeid(T1).name() << " and " << typeid(T2).name();
throw std::domain_error(ss.str());
return nullptr; // Must return something
}
template<> auto t_add(const int& x, const int& y) {
Expand Down
14 changes: 10 additions & 4 deletions src/operations/boolean.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#include "operations/boolean.h"
#include "util.h"
#include "operations/util.h"
#include <sstream>

template<typename T1, typename T2>
auto t_and(const T1&, const T2&) {
throw std::domain_error((std::ostringstream{} << "Unable to AND types " << typeid(T1).name() << " and " << typeid(T2).name()).str());
std::ostringstream ss{};
ss << "Unable to AND types " << typeid(T1).name() << " and " << typeid(T2).name();
throw std::domain_error(ss.str());
return nullptr; // Must return something
}
template<typename T1, typename T2>
auto t_or(const T1&, const T2&) {
throw std::domain_error((std::ostringstream{} << "Unable to OR types " << typeid(T1).name() << " and " << typeid(T2).name()).str());
std::ostringstream ss{};
ss << "Unable to OR types " << typeid(T1).name() << " and " << typeid(T2).name();
throw std::domain_error(ss.str());
return nullptr; // Must return something
}
template<typename T1>
auto t_not(const T1&) {
throw std::domain_error((std::ostringstream{} << "Unable to NOT type " << typeid(T1).name()).str());
std::ostringstream ss{};
ss << "Unable to NOT type " << typeid(T1).name();
throw std::domain_error(ss.str());
return nullptr; // Must return something
}

Expand Down
18 changes: 12 additions & 6 deletions src/operations/divide.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#include "operations/divide.h"
#include "util.h"
#include "operations/util.h"
#include <sstream>

template<typename T1, typename T2>
auto t_divide(const T1&, const T2&) {
throw std::domain_error((std::ostringstream{} << "Unable to divide type " << typeid(T1).name() << " and " << typeid(T2).name()).str());
std::ostringstream ss{};
ss << "Unable to divide type " << typeid(T1).name() << " and " << typeid(T2).name();
throw std::domain_error(ss.str());
return nullptr; // Must return something
}
template<> auto t_divide(const int& x, const int& y) {
if(y == 0 || (x == INT32_MIN && y == -1)) throw std::domain_error("Cannot divide with zero or INT_MIN / -1");
if(y == 0 || (x == INT32_MIN && y == -1))
throw std::domain_error("Cannot divide with zero or INT_MIN / -1");
return x / y;
}
template<> auto t_divide(const float& x, const int& y) {
if(y == 0) throw std::domain_error("Cannot divide with zero or INT_MIN / -1");
if(y == 0)
throw std::domain_error("Cannot divide with zero or INT_MIN / -1");
return x / y;
}
template<> auto t_divide(const int& x, const float& y) {
if(y == 0.0f) throw std::domain_error("Cannot divide with zero or INT_MIN / -1");
if(y == 0.0f)
throw std::domain_error("Cannot divide with zero or INT_MIN / -1");
return x / y;
}
template<> auto t_divide(const float& x, const float& y) {
if(y == 0.0f) throw std::domain_error("Cannot divide with zero or INT_MIN / -1");
if(y == 0.0f)
throw std::domain_error("Cannot divide with zero or INT_MIN / -1");
return x / y;
}

Expand Down
6 changes: 4 additions & 2 deletions src/operations/multiply.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "operations/multiply.h"
#include "util.h"
#include "operations/util.h"
#include <sstream>

template<typename T1, typename T2>
auto t_multiply(const T1&, const T2&) {
throw std::domain_error((std::ostringstream{} << "Unable to multiply type " << typeid(T1).name() << " and " << typeid(T2).name()).str());
std::ostringstream ss{};
ss << "Unable to multiply type " << typeid(T1).name() << " and " << typeid(T2).name();
throw std::domain_error(ss.str());
return nullptr; // Must return something
}
template<> auto t_multiply(const int& x, const int& y) {
Expand Down
6 changes: 4 additions & 2 deletions src/operations/subtract.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "operations/subtract.h"
#include "util.h"
#include "operations/util.h"
#include <sstream>

template<typename T1, typename T2>
auto t_subtract(const T1&, const T2&) {
throw std::domain_error((std::ostringstream{} << "Unable to subtract type " << typeid(T1).name() << " and " << typeid(T2).name()).str());
std::ostringstream ss{};
ss << "Unable to subtract type " << typeid(T1).name() << " and " << typeid(T2).name();
throw std::domain_error(ss.str());
return nullptr; // Must return something
}
template<> auto t_subtract(const int& x, const int& y) {
Expand Down
6 changes: 3 additions & 3 deletions src/parser/parser.y
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%skeleton "lalr1.cc"
%require "3.8"
%header
%require "3.5"

%define api.token.raw

Expand All @@ -23,7 +22,7 @@

// Enable parser tracing and detailed errors
%define parse.trace
%define parse.error detailed
%define parse.error verbose
// Enable full lookahead to avoid incorrect error information
// See https://www.gnu.org/software/bison/manual/html_node/LAC.html for details
%define parse.lac full
Expand All @@ -34,6 +33,7 @@
}

%define api.token.prefix {TOK_}
%token YYEOF 0
%token
ASSIGN ":="
MINUS "-"
Expand Down

0 comments on commit 9b2f35b

Please sign in to comment.