mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Merge pull request #21 from hvellyr/master
Supporting CI on windows (using appveyor) and more compiler warning fixes
This commit is contained in:
commit
7ef51f6acb
@ -1,5 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
add_definitions("-std=c++1y")
|
|
||||||
|
|
||||||
# Check if a supported compiler is used and add c++14 flag:
|
# Check if a supported compiler is used and add c++14 flag:
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
@ -7,7 +6,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|||||||
message(FATAL_ERROR "Need at least gcc 4.9 to compile.")
|
message(FATAL_ERROR "Need at least gcc 4.9 to compile.")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
elseif(MSVC)
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
|
||||||
message(FATAL_ERROR "Visual Studio 2015 or newer is required.")
|
message(FATAL_ERROR "Visual Studio 2015 or newer is required.")
|
||||||
endif()
|
endif()
|
||||||
@ -53,14 +52,25 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
|
|||||||
)
|
)
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
set(warning_options -Wall -Wpedantic -Wextra)
|
set(warning_options -Wall -Wpedantic -Wextra)
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
elseif(MSVC)
|
||||||
set(warning_options /WX /W4 /wd4503 /wd4512)
|
set(warning_options /W4 /wd4503 /wd4512)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
set(add_link_deps pthread)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
add_subdirectory(lint)
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
add_subdirectory(example)
|
add_subdirectory(example)
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
add_subdirectory(lint)
|
||||||
add_subdirectory(language/pl0)
|
add_subdirectory(language/pl0)
|
||||||
add_subdirectory(language/culebra)
|
add_subdirectory(language/culebra)
|
||||||
|
endif()
|
16
appveyor.yml
Normal file
16
appveyor.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
clone_depth: 5
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- CMAKE_GENERATOR: "Visual Studio 14 2015"
|
||||||
|
CONFIGURATION: Release
|
||||||
|
- CMAKE_GENERATOR: "Visual Studio 14 2015 Win64"
|
||||||
|
CONFIGURATION: Release
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- mkdir build && cd build
|
||||||
|
- cmake .. -Wno-dev -G"%CMAKE_GENERATOR%"
|
||||||
|
- cmake --build . --config %CONFIGURATION%
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- ctest -C %CONFIGURATION% -V
|
@ -1,12 +1,17 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
include_directories(..)
|
include_directories(..)
|
||||||
add_compile_options(${cxx11_options} ${warning_options})
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(${cxx11_options} /W3)
|
||||||
|
else()
|
||||||
|
add_compile_options(${cxx11_options})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(calc calc.cc)
|
add_executable(calc calc.cc)
|
||||||
target_link_libraries(calc pthread)
|
target_link_libraries(calc ${add_link_deps})
|
||||||
|
|
||||||
add_executable(calc2 calc2.cc)
|
add_executable(calc2 calc2.cc)
|
||||||
target_link_libraries(calc2 pthread)
|
target_link_libraries(calc2 ${add_link_deps})
|
||||||
|
|
||||||
add_executable(calc3 calc3.cc)
|
add_executable(calc3 calc3.cc)
|
||||||
target_link_libraries(calc3 pthread)
|
target_link_libraries(calc3 ${add_link_deps})
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
include_directories(../..)
|
include_directories(../..)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(${cxx11_options} /W3)
|
||||||
|
add_definitions(-DUNICODE)
|
||||||
|
else()
|
||||||
|
add_compile_options(${cxx11_options})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(culebra main.cc)
|
add_executable(culebra main.cc)
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
include_directories(../..)
|
include_directories(../..)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(${cxx11_options} /W0)
|
||||||
|
else()
|
||||||
|
add_compile_options(${cxx11_options})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(pl0 pl0.cc)
|
add_executable(pl0 pl0.cc)
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
include_directories(..)
|
include_directories(..)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(${cxx11_options} /W3)
|
||||||
|
else()
|
||||||
|
add_compile_options(${cxx11_options})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(peglint peglint.cc server.cc)
|
add_executable(peglint peglint.cc server.cc)
|
||||||
|
12
peglib.h
12
peglib.h
@ -5,8 +5,8 @@
|
|||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef _CPPPEGLIB_PEGLIB_H_
|
#ifndef CPPPEGLIB_PEGLIB_H
|
||||||
#define _CPPPEGLIB_PEGLIB_H_
|
#define CPPPEGLIB_PEGLIB_H
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@ -1104,6 +1104,8 @@ struct Ope::Visitor
|
|||||||
|
|
||||||
struct AssignIDToDefinition : public Ope::Visitor
|
struct AssignIDToDefinition : public Ope::Visitor
|
||||||
{
|
{
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
void visit(Sequence& ope) override {
|
void visit(Sequence& ope) override {
|
||||||
for (auto op: ope.opes_) {
|
for (auto op: ope.opes_) {
|
||||||
op->accept(*this);
|
op->accept(*this);
|
||||||
@ -1133,6 +1135,8 @@ struct IsToken : public Ope::Visitor
|
|||||||
{
|
{
|
||||||
IsToken() : has_token_boundary(false), has_rule(false) {}
|
IsToken() : has_token_boundary(false), has_rule(false) {}
|
||||||
|
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
void visit(Sequence& ope) override {
|
void visit(Sequence& ope) override {
|
||||||
for (auto op: ope.opes_) {
|
for (auto op: ope.opes_) {
|
||||||
op->accept(*this);
|
op->accept(*this);
|
||||||
@ -1352,7 +1356,7 @@ private:
|
|||||||
inline size_t LiteralString::parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const {
|
inline size_t LiteralString::parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const {
|
||||||
c.trace("LiteralString", s, n, sv, dt);
|
c.trace("LiteralString", s, n, sv, dt);
|
||||||
|
|
||||||
auto i = 0u;
|
size_t i = 0;
|
||||||
for (; i < lit_.size(); i++) {
|
for (; i < lit_.size(); i++) {
|
||||||
if (i >= n || s[i] != lit_[i]) {
|
if (i >= n || s[i] != lit_[i]) {
|
||||||
c.set_error_pos(s);
|
c.set_error_pos(s);
|
||||||
@ -1661,6 +1665,8 @@ private:
|
|||||||
DetectLeftRecursion(const std::string& name)
|
DetectLeftRecursion(const std::string& name)
|
||||||
: s_(nullptr), name_(name), done_(false) {}
|
: s_(nullptr), name_(name), done_(false) {}
|
||||||
|
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
void visit(Sequence& ope) override {
|
void visit(Sequence& ope) override {
|
||||||
for (auto op: ope.opes_) {
|
for (auto op: ope.opes_) {
|
||||||
op->accept(*this);
|
op->accept(*this);
|
||||||
|
@ -3,6 +3,6 @@ include_directories(..)
|
|||||||
add_compile_options(${cxx11_options} ${warning_options})
|
add_compile_options(${cxx11_options} ${warning_options})
|
||||||
|
|
||||||
add_executable(test-main test.cc)
|
add_executable(test-main test.cc)
|
||||||
target_link_libraries(test-main pthread)
|
target_link_libraries(test-main ${add_link_deps})
|
||||||
|
|
||||||
add_test(TestMain test-main)
|
add_test(TestMain test-main)
|
||||||
|
Loading…
Reference in New Issue
Block a user