Removed unused antlr4 files
Change-Id: Ic1f222e726694ffc5afe158ae1839ce9c55ec6d5 Reviewed-on: https://chromium-review.googlesource.com/1004996 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Commit-Queue: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#52517}
This commit is contained in:
parent
36d0336e66
commit
297c0b7521
138
third_party/antlr4/runtime/Cpp/CMakeLists.txt
vendored
138
third_party/antlr4/runtime/Cpp/CMakeLists.txt
vendored
@ -1,138 +0,0 @@
|
||||
# -*- mode:cmake -*-
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
# 2.8 needed because of ExternalProject
|
||||
|
||||
# Detect build type, fallback to release and throw a warning if use didn't specify any
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(WARNING "Build type not set, falling back to Release mode.
|
||||
To specify build type use:
|
||||
-DCMAKE_BUILD_TYPE=<mode> where <mode> is Debug or Release.")
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
|
||||
"Choose the type of build, options are: Debug Release."
|
||||
FORCE)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
if(NOT WITH_DEMO)
|
||||
message(STATUS "Building without demo. To enable demo build use: -DWITH_DEMO=True")
|
||||
set(WITH_DEMO False CACHE STRING
|
||||
"Chose to build with or without demo executable"
|
||||
FORCE)
|
||||
endif(NOT WITH_DEMO)
|
||||
|
||||
option(WITH_LIBCXX "Building with clang++ and libc++(in Linux). To enable with: -DWITH_LIBCXX=On" On)
|
||||
|
||||
project(LIBANTLR4)
|
||||
|
||||
if(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR
|
||||
CMAKE_VERSION VERSION_GREATER "3.0.0")
|
||||
CMAKE_POLICY(SET CMP0026 NEW)
|
||||
CMAKE_POLICY(SET CMP0054 OLD)
|
||||
CMAKE_POLICY(SET CMP0045 OLD)
|
||||
CMAKE_POLICY(SET CMP0042 OLD)
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_EQUAL "3.3.0" OR
|
||||
CMAKE_VERSION VERSION_GREATER "3.3.0")
|
||||
CMAKE_POLICY(SET CMP0059 OLD)
|
||||
CMAKE_POLICY(SET CMP0054 OLD)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(UUID REQUIRED uuid)
|
||||
endif()
|
||||
if(APPLE)
|
||||
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
||||
endif()
|
||||
|
||||
file(STRINGS "VERSION" ANTLR_VERSION)
|
||||
|
||||
if (WITH_DEMO)
|
||||
# Java is not necessary if building without demos.
|
||||
find_package(Java COMPONENTS Runtime REQUIRED)
|
||||
|
||||
if (NOT ANTLR_JAR_LOCATION)
|
||||
message(FATAL_ERROR "Missing antlr4.jar location. You can specify it's path using: -DANTLR_JAR_LOCATION=<path>")
|
||||
else()
|
||||
get_filename_component(ANTLR_NAME ${ANTLR_JAR_LOCATION} NAME_WE)
|
||||
if(NOT EXISTS "${ANTLR_JAR_LOCATION}")
|
||||
message(FATAL_ERROR "Unable to find ${ANTLR_NAME} in ${ANTLR_JAR_LOCATION}")
|
||||
else()
|
||||
message(STATUS "Found ${ANTLR_NAME}: ${ANTLR_JAR_LOCATION}")
|
||||
endif()
|
||||
endif()
|
||||
endif(WITH_DEMO)
|
||||
|
||||
if (MSVC_VERSION)
|
||||
set(MY_CXX_WARNING_FLAGS " /W4")
|
||||
else()
|
||||
set(MY_CXX_WARNING_FLAGS " -Wall -pedantic -W")
|
||||
endif()
|
||||
|
||||
# Initialize CXXFLAGS.
|
||||
if("${CMAKE_VERSION}" VERSION_GREATER 3.1.0)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -std=c++11")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_WARNING_FLAGS}")
|
||||
if (MSVC_VERSION)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /MP ${MY_CXX_WARNING_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /O1 /Oi /Ob2 /Gy /MP /DNDEBUG ${MY_CXX_WARNING_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /Oi /Ob2 /Gy /MP /DNDEBUG ${MY_CXX_WARNING_FLGAS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /O2 /Oi /Ob2 /Gy /MP /Zi ${MY_CXX_WARNING_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g ${MY_CXX_WARNING_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG ${MY_CXX_WARNING_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG ${MY_CXX_WARNING_FLGAS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g ${MY_CXX_WARNING_FLAGS}")
|
||||
endif()
|
||||
|
||||
# Compiler-specific C++11 activation.
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
|
||||
# Just g++-5.0 and greater contain <codecvt> header. (test in ubuntu)
|
||||
if (NOT (GCC_VERSION VERSION_GREATER 5.0 OR GCC_VERSION VERSION_EQUAL 5.0))
|
||||
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 5.0 or greater.")
|
||||
endif ()
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
|
||||
if (NOT (CLANG_VERSION VERSION_GREATER 4.2.1 OR CLANG_VERSION VERSION_EQUAL 4.2.1))
|
||||
message(FATAL_ERROR "${PROJECT_NAME} requires clang 4.2.1 or greater.")
|
||||
endif ()
|
||||
# You can use libc++ to compile this project when g++ is NOT greater than or equal to 5.0.
|
||||
if (WITH_LIBCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
elseif ( MSVC_VERSION GREATER 1800 OR MSVC_VERSION EQUAL 1800 )
|
||||
# Visual Studio 2012+ supports c++11 features
|
||||
else ()
|
||||
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
|
||||
endif ()
|
||||
|
||||
|
||||
add_subdirectory(runtime)
|
||||
if (WITH_DEMO)
|
||||
add_subdirectory(demo)
|
||||
endif(WITH_DEMO)
|
||||
|
||||
if( EXISTS LICENSE.txt)
|
||||
install(FILES LICENSE.txt
|
||||
DESTINATION "share/doc/libantlr4")
|
||||
elseif(EXISTS ../../LICENSE.txt)
|
||||
install(FILES ../../LICENSE.txt
|
||||
DESTINATION "share/doc/libantlr4")
|
||||
endif()
|
||||
|
||||
install(FILES README.md VERSION
|
||||
DESTINATION "share/doc/libantlr4")
|
@ -1,223 +0,0 @@
|
||||
# -*- mode:cmake -*-
|
||||
#
|
||||
# This Cmake file is for those using a superbuild Cmake Pattern, it
|
||||
# will download the tools and build locally
|
||||
#
|
||||
# use 2the antlr4cpp_process_grammar to support multiple grammars in the
|
||||
# same project
|
||||
#
|
||||
# - Getting quicky started with Antlr4cpp
|
||||
#
|
||||
# Here is how you can use this external project to create the antlr4cpp
|
||||
# demo to start your project off.
|
||||
#
|
||||
# create your project source folder somewhere. e.g. ~/srcfolder/
|
||||
# + make a subfolder cmake
|
||||
# + Copy this file to srcfolder/cmake
|
||||
# + cut below and use it to create srcfolder/CMakeLists.txt,
|
||||
# + from https://github.com/DanMcLaughlin/antlr4/tree/master/runtime/Cpp/demo Copy main.cpp, TLexer.g4 and TParser.g4 to ./srcfolder/
|
||||
#
|
||||
# next make a build folder e.g. ~/buildfolder/
|
||||
# from the buildfolder, run cmake ~/srcfolder; make
|
||||
#
|
||||
###############################################################
|
||||
# # minimum required CMAKE version
|
||||
# CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.2 FATAL_ERROR)
|
||||
#
|
||||
# LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
|
||||
#
|
||||
# # compiler must be 11 or 14
|
||||
# SET (CMAKE_CXX_STANDARD 11)
|
||||
#
|
||||
# # set variable pointing to the antlr tool that supports C++
|
||||
# set(ANTLR4CPP_JAR_LOCATION /home/user/antlr4-4.5.4-SNAPSHOT.jar)
|
||||
# # add external build for antlrcpp
|
||||
# include( ExternalAntlr4Cpp )
|
||||
# # add antrl4cpp artifacts to project environment
|
||||
# include_directories( ${ANTLR4CPP_INCLUDE_DIRS} )
|
||||
# link_directories( ${ANTLR4CPP_LIBS} )
|
||||
# message(STATUS "Found antlr4cpp libs: ${ANTLR4CPP_LIBS} and includes: ${ANTLR4CPP_INCLUDE_DIRS} ")
|
||||
#
|
||||
# # Call macro to add lexer and grammar to your build dependencies.
|
||||
# antlr4cpp_process_grammar(demo antlrcpptest
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/TLexer.g4
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/TParser.g4)
|
||||
# # include generated files in project environment
|
||||
# include_directories(${antlr4cpp_include_dirs_antlrcpptest})
|
||||
#
|
||||
# # add generated grammar to demo binary target
|
||||
# add_executable(demo main.cpp ${antlr4cpp_src_files_antlrcpptest})
|
||||
# add_dependencies(demo antlr4cpp antlr4cpp_generation_antlrcpptest)
|
||||
# target_link_libraries(demo antlr4-runtime)
|
||||
#
|
||||
###############################################################
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.2)
|
||||
PROJECT(antlr4cpp_fetcher CXX)
|
||||
INCLUDE(ExternalProject)
|
||||
FIND_PACKAGE(Git REQUIRED)
|
||||
|
||||
# only JRE required
|
||||
FIND_PACKAGE(Java COMPONENTS Runtime REQUIRED)
|
||||
|
||||
############ Download and Generate runtime #################
|
||||
set(ANTLR4CPP_EXTERNAL_ROOT ${CMAKE_BINARY_DIR}/externals/antlr4cpp)
|
||||
|
||||
# external repository
|
||||
# GIT_REPOSITORY https://github.com/antlr/antlr4.git
|
||||
set(ANTLR4CPP_EXTERNAL_REPO "https://github.com/antlr/antlr4.git")
|
||||
set(ANTLR4CPP_EXTERNAL_TAG "4.7.1")
|
||||
|
||||
if(NOT EXISTS "${ANTLR4CPP_JAR_LOCATION}")
|
||||
message(FATAL_ERROR "Unable to find antlr tool. ANTLR4CPP_JAR_LOCATION:${ANTLR4CPP_JAR_LOCATION}")
|
||||
endif()
|
||||
|
||||
# default path for source files
|
||||
if (NOT ANTLR4CPP_GENERATED_SRC_DIR)
|
||||
set(ANTLR4CPP_GENERATED_SRC_DIR ${CMAKE_BINARY_DIR}/antlr4cpp_generated_src)
|
||||
endif()
|
||||
|
||||
# !TODO! This should probably check with Cmake Find first?
|
||||
# set(ANTLR4CPP_JAR_LOCATION ${ANTLR4CPP_EXTERNAL_ROOT}/${ANTLR4CPP_JAR_NAME})
|
||||
#
|
||||
# !TODO! Ensure Antlr tool available - copy from internet
|
||||
#
|
||||
# # !TODO! this shold be calculated based on the tags
|
||||
# if (NOT ANTLR4CPP_JAR_NAME)
|
||||
# # default location to find antlr Java binary
|
||||
# set(ANTLR4CPP_JAR_NAME antlr4-4.5.4-SNAPSHOT.jar)
|
||||
# endif()
|
||||
#
|
||||
# if(NOT EXISTS "${ANTLR4CPP_JAR_LOCATION}")
|
||||
# # download Java tool if not installed
|
||||
# ExternalProject_ADD(
|
||||
# #--External-project-name------
|
||||
# antlrtool
|
||||
# #--Core-directories-----------
|
||||
# PREFIX ${ANTLR4CPP_EXTERNAL_ROOT}
|
||||
# #--Download step--------------
|
||||
# DOWNLOAD_DIR ${ANTLR4CPP_EXTERNAL_ROOT}
|
||||
# DOWNLOAD_COMMAND ""
|
||||
# # URL http://www.antlr.org/download/${ANTLR4CPP_JAR_NAME}
|
||||
# # antlr4-4.5.4-SNAPSHOT.jar
|
||||
# # GIT_TAG v4.5.4
|
||||
# TIMEOUT 10
|
||||
# LOG_DOWNLOAD ON
|
||||
# #--Update step----------
|
||||
# # UPDATE_COMMAND ${GIT_EXECUTABLE} pull
|
||||
# #--Patch step----------
|
||||
# # PATCH_COMMAND sh -c "cp <SOURCE_DIR>/scripts/CMakeLists.txt <SOURCE_DIR>"
|
||||
# #--Configure step-------------
|
||||
# CMAKE_ARGS ""
|
||||
# CONFIGURE_COMMAND ""
|
||||
# LOG_CONFIGURE ON
|
||||
# #--Build step-----------------
|
||||
# BUILD_COMMAND ""
|
||||
# LOG_BUILD ON
|
||||
# #--Install step---------------
|
||||
# INSTALL_COMMAND ""
|
||||
# )
|
||||
# # Verify Antlr Available
|
||||
# if(NOT EXISTS "${ANTLR4CPP_JAR_LOCATION}")
|
||||
# message(FATAL_ERROR "Unable to find ANTLR4CPP_JAR_LOCATION:${ANTLR4CPP_JAR_LOCATION} -> ${ANTLR4CPP_JAR_NAME} not in ${ANTLR4CPP_DIR} ")
|
||||
# endif()
|
||||
# endif()
|
||||
|
||||
# download runtime environment
|
||||
ExternalProject_ADD(
|
||||
#--External-project-name------
|
||||
antlr4cpp
|
||||
#--Depend-on-antrl-tool-----------
|
||||
# DEPENDS antlrtool
|
||||
#--Core-directories-----------
|
||||
PREFIX ${ANTLR4CPP_EXTERNAL_ROOT}
|
||||
#--Download step--------------
|
||||
GIT_REPOSITORY ${ANTLR4CPP_EXTERNAL_REPO}
|
||||
# GIT_TAG ${ANTLR4CPP_EXTERNAL_TAG}
|
||||
TIMEOUT 10
|
||||
LOG_DOWNLOAD ON
|
||||
#--Update step----------
|
||||
UPDATE_COMMAND ${GIT_EXECUTABLE} pull
|
||||
#--Patch step----------
|
||||
# PATCH_COMMAND sh -c "cp <SOURCE_DIR>/scripts/CMakeLists.txt <SOURCE_DIR>"
|
||||
#--Configure step-------------
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release -DANTLR4CPP_JAR_LOCATION=${ANTLR4CPP_JAR_LOCATION} -DBUILD_SHARED_LIBS=ON -BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_SOURCE_DIR:PATH=<SOURCE_DIR>/runtime/Cpp <SOURCE_DIR>/runtime/Cpp
|
||||
LOG_CONFIGURE ON
|
||||
#--Build step-----------------
|
||||
# BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
|
||||
LOG_BUILD ON
|
||||
#--Install step---------------
|
||||
# INSTALL_COMMAND ""
|
||||
# INSTALL_DIR ${CMAKE_BINARY_DIR}/
|
||||
#--Install step---------------
|
||||
# INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(antlr4cpp INSTALL_DIR)
|
||||
|
||||
list(APPEND ANTLR4CPP_INCLUDE_DIRS ${INSTALL_DIR}/include/antlr4-runtime)
|
||||
foreach(src_path misc atn dfa tree support)
|
||||
list(APPEND ANTLR4CPP_INCLUDE_DIRS ${INSTALL_DIR}/include/antlr4-runtime/${src_path})
|
||||
endforeach(src_path)
|
||||
|
||||
set(ANTLR4CPP_LIBS "${INSTALL_DIR}/lib")
|
||||
|
||||
# antlr4_shared ${INSTALL_DIR}/lib/libantlr4-runtime.so
|
||||
# antlr4_static ${INSTALL_DIR}/lib/libantlr4-runtime.a
|
||||
|
||||
############ Generate runtime #################
|
||||
# macro to add dependencies to target
|
||||
#
|
||||
# Param 1 project name
|
||||
# Param 1 namespace (postfix for dependencies)
|
||||
# Param 2 Lexer file (full path)
|
||||
# Param 3 Parser File (full path)
|
||||
#
|
||||
# output
|
||||
#
|
||||
# antlr4cpp_src_files_{namespace} - src files for add_executable
|
||||
# antlr4cpp_include_dirs_{namespace} - include dir for generated headers
|
||||
# antlr4cpp_generation_{namespace} - for add_dependencies tracking
|
||||
|
||||
macro(antlr4cpp_process_grammar
|
||||
antlr4cpp_project
|
||||
antlr4cpp_project_namespace
|
||||
antlr4cpp_grammar_lexer
|
||||
antlr4cpp_grammar_parser)
|
||||
|
||||
if(EXISTS "${ANTLR4CPP_JAR_LOCATION}")
|
||||
message(STATUS "Found antlr tool: ${ANTLR4CPP_JAR_LOCATION}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to find antlr tool. ANTLR4CPP_JAR_LOCATION:${ANTLR4CPP_JAR_LOCATION}")
|
||||
endif()
|
||||
|
||||
add_custom_target("antlr4cpp_generation_${antlr4cpp_project_namespace}"
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E make_directory ${ANTLR4CPP_GENERATED_SRC_DIR}
|
||||
COMMAND
|
||||
"${Java_JAVA_EXECUTABLE}" -jar "${ANTLR4CPP_JAR_LOCATION}" -Werror -Dlanguage=Cpp -listener -visitor -o "${ANTLR4CPP_GENERATED_SRC_DIR}/${antlr4cpp_project_namespace}" -package ${antlr4cpp_project_namespace} "${antlr4cpp_grammar_lexer}" "${antlr4cpp_grammar_parser}"
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||
DEPENDS "${antlr4cpp_grammar_lexer}" "${antlr4cpp_grammar_parser}"
|
||||
)
|
||||
|
||||
# Find all the input files
|
||||
FILE(GLOB generated_files ${ANTLR4CPP_GENERATED_SRC_DIR}/${antlr4cpp_project_namespace}/*.cpp)
|
||||
|
||||
# export generated cpp files into list
|
||||
foreach(generated_file ${generated_files})
|
||||
list(APPEND antlr4cpp_src_files_${antlr4cpp_project_namespace} ${generated_file})
|
||||
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set_source_files_properties(
|
||||
${generated_file}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS -Wno-overloaded-virtual
|
||||
)
|
||||
endif ()
|
||||
endforeach(generated_file)
|
||||
message(STATUS "Antlr4Cpp ${antlr4cpp_project_namespace} Generated: ${generated_files}")
|
||||
|
||||
# export generated include directory
|
||||
set(antlr4cpp_include_dirs_${antlr4cpp_project_namespace} ${ANTLR4CPP_GENERATED_SRC_DIR}/${antlr4cpp_project_namespace})
|
||||
message(STATUS "Antlr4Cpp ${antlr4cpp_project_namespace} include: ${ANTLR4CPP_GENERATED_SRC_DIR}/${antlr4cpp_project_namespace}")
|
||||
|
||||
endmacro()
|
@ -1,80 +0,0 @@
|
||||
# -*- mode:cmake -*-
|
||||
if(NOT UNIX)
|
||||
message(WARNING "Unsupported operating system")
|
||||
endif()
|
||||
|
||||
set(antlr4-demo-GENERATED_SRC
|
||||
${PROJECT_SOURCE_DIR}/demo/generated/TLexer.cpp
|
||||
${PROJECT_SOURCE_DIR}/demo/generated/TParser.cpp
|
||||
${PROJECT_SOURCE_DIR}/demo/generated/TParserBaseListener.cpp
|
||||
${PROJECT_SOURCE_DIR}/demo/generated/TParserBaseVisitor.cpp
|
||||
${PROJECT_SOURCE_DIR}/demo/generated/TParserListener.cpp
|
||||
${PROJECT_SOURCE_DIR}/demo/generated/TParserVisitor.cpp
|
||||
)
|
||||
|
||||
foreach( src_file ${antlr4-demo-GENERATED_SRC} )
|
||||
set_source_files_properties(
|
||||
${src_file}
|
||||
PROPERTIES
|
||||
GENERATED TRUE
|
||||
)
|
||||
endforeach( src_file ${antlr4-demo-GENERATED_SRC} )
|
||||
|
||||
add_custom_target(GenerateParser DEPENDS ${antlr4-demo-GENERATED_SRC})
|
||||
add_custom_command(OUTPUT ${antlr4-demo-GENERATED_SRC}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/demo/generated/
|
||||
COMMAND
|
||||
"${Java_JAVA_EXECUTABLE}" -jar ${ANTLR_JAR_LOCATION} -Werror -Dlanguage=Cpp -listener -visitor -o ${PROJECT_SOURCE_DIR}/demo/generated/ -package antlrcpptest ${PROJECT_SOURCE_DIR}/demo/TLexer.g4 ${PROJECT_SOURCE_DIR}/demo/TParser.g4
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/demo/TLexer.g4 ${PROJECT_SOURCE_DIR}/demo/TParser.g4
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/runtime/src
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/misc
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/atn
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/dfa
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/tree
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/support
|
||||
${PROJECT_SOURCE_DIR}/demo/generated
|
||||
)
|
||||
|
||||
#file(GLOB antlr4-demo_SRC "${PROJECT_SOURCE_DIR}/demo/generated/*")
|
||||
set(antlr4-demo_SRC
|
||||
${PROJECT_SOURCE_DIR}/demo/Linux/main.cpp
|
||||
${antlr4-demo-GENERATED_SRC}
|
||||
)
|
||||
|
||||
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set (flags_1 "-Wno-overloaded-virtual")
|
||||
else()
|
||||
set (flags_1 "-MP /wd4251")
|
||||
endif()
|
||||
|
||||
foreach( src_file ${antlr4-demo_SRC} )
|
||||
set_source_files_properties(
|
||||
${src_file}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${COMPILE_FLAGS} ${flags_1}"
|
||||
)
|
||||
endforeach( src_file ${antlr4-demo_SRC} )
|
||||
|
||||
add_executable(antlr4-demo
|
||||
${antlr4-demo_SRC}
|
||||
)
|
||||
#add_precompiled_header(antlr4-demo ${PROJECT_SOURCE_DIR}/runtime/src/antlrcpp-Prefix.h)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
target_compile_options(antlr4-demo PRIVATE "/MT$<$<CONFIG:Debug>:d>")
|
||||
endif()
|
||||
|
||||
add_dependencies(antlr4-demo GenerateParser)
|
||||
|
||||
target_link_libraries(antlr4-demo antlr4_static)
|
||||
|
||||
install(TARGETS antlr4-demo
|
||||
DESTINATION "share"
|
||||
COMPONENT dev
|
||||
)
|
||||
|
@ -1,39 +0,0 @@
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
//
|
||||
// main.cpp
|
||||
// antlr4-cpp-demo
|
||||
//
|
||||
// Created by Mike Lischke on 13.03.16.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "TLexer.h"
|
||||
#include "TParser.h"
|
||||
#include "antlr4-runtime.h"
|
||||
|
||||
using namespace antlrcpptest;
|
||||
using namespace antlr4;
|
||||
|
||||
int main(int, const char**) {
|
||||
ANTLRInputStream input(
|
||||
u8"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);");
|
||||
TLexer lexer(&input);
|
||||
CommonTokenStream tokens(&lexer);
|
||||
|
||||
tokens.fill();
|
||||
for (auto token : tokens.getTokens()) {
|
||||
std::cout << token->toString() << std::endl;
|
||||
}
|
||||
|
||||
TParser parser(&tokens);
|
||||
tree::ParseTree* tree = parser.main();
|
||||
|
||||
std::cout << tree->toStringTree(&parser) << std::endl << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
//
|
||||
// main.cpp
|
||||
// antlr4-cpp-demo
|
||||
//
|
||||
// Created by Mike Lischke on 13.03.16.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "TLexer.h"
|
||||
#include "TParser.h"
|
||||
#include "antlr4-runtime.h"
|
||||
|
||||
using namespace antlrcpptest;
|
||||
using namespace antlr4;
|
||||
|
||||
int main(int, const char**) {
|
||||
ANTLRInputStream input(
|
||||
u8"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);");
|
||||
TLexer lexer(&input);
|
||||
CommonTokenStream tokens(&lexer);
|
||||
|
||||
tokens.fill();
|
||||
for (auto token : tokens.getTokens()) {
|
||||
std::cout << token->toString() << std::endl;
|
||||
}
|
||||
|
||||
TParser parser(&tokens);
|
||||
tree::ParseTree* tree = parser.main();
|
||||
|
||||
std::cout << tree->toStringTree(&parser) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
24
third_party/antlr4/runtime/Cpp/demo/Mac/antlrcpp
vendored
24
third_party/antlr4/runtime/Cpp/demo/Mac/antlrcpp
vendored
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
566
third_party/antlr4/runtime/Cpp/demo/Mac/antlrcpp.rej
vendored
566
third_party/antlr4/runtime/Cpp/demo/Mac/antlrcpp.rej
vendored
@ -1,566 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ third_party/antlr4/runtime/Cpp/demo/Mac/antlrcpp Tests/InputHandlingTests.mm
|
||||
@@ -0,0 +1,172 @@
|
||||
+/*
|
||||
+ * [The "BSD license"]
|
||||
+ * Copyright (c) 2016 Mike Lischke
|
||||
+ * All rights reserved.
|
||||
+ *
|
||||
+ * Redistribution and use in source and binary forms, with or without
|
||||
+ * modification, are permitted provided that the following conditions
|
||||
+ * are met:
|
||||
+ *
|
||||
+ * 1. Redistributions of source code must retain the above copyright
|
||||
+ * notice, this list of conditions and the following disclaimer.
|
||||
+ * 2. Redistributions in binary form must reproduce the above copyright
|
||||
+ * notice, this list of conditions and the following disclaimer in the
|
||||
+ * documentation and/or other materials provided with the distribution.
|
||||
+ * 3. The name of the author may not be used to endorse or promote products
|
||||
+ * derived from this software without specific prior written permission.
|
||||
+ *
|
||||
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+ */
|
||||
+
|
||||
+#import <XCTest/XCTest.h>
|
||||
+
|
||||
+#include "ANTLRInputStream.h"
|
||||
+#include "Exceptions.h"
|
||||
+#include "Interval.h"
|
||||
+#include "UnbufferedTokenStream.h"
|
||||
+#include "StringUtils.h"
|
||||
+
|
||||
+using namespace antlrcpp;
|
||||
+using namespace antlr4;
|
||||
+using namespace antlr4::misc;
|
||||
+
|
||||
+@interface InputHandlingTests : XCTestCase
|
||||
+
|
||||
+@end
|
||||
+
|
||||
+@implementation InputHandlingTests
|
||||
+
|
||||
+- (void)setUp {
|
||||
+ [super setUp];
|
||||
+ // Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
+}
|
||||
+
|
||||
+- (void)tearDown {
|
||||
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
+ [super tearDown];
|
||||
+}
|
||||
+
|
||||
+- (void)testANTLRInputStreamCreation {
|
||||
+ ANTLRInputStream stream1;
|
||||
+ XCTAssert(stream1.toString().empty());
|
||||
+ XCTAssertEqual(stream1.index(), 0U);
|
||||
+
|
||||
+ ANTLRInputStream stream2("To be or not to be");
|
||||
+ XCTAssert(stream2.toString() == "To be or not to be");
|
||||
+ XCTAssertEqual(stream2.index(), 0U);
|
||||
+ XCTAssertEqual(stream2.size(), 18U);
|
||||
+
|
||||
+ char data[] = "Lorem ipsum dolor sit amet";
|
||||
+ ANTLRInputStream stream3(data, sizeof(data) / sizeof(data[0]));
|
||||
+ XCTAssert(stream3.toString() == std::string("Lorem ipsum dolor sit amet\0", 27));
|
||||
+ XCTAssertEqual(stream3.index(), 0U);
|
||||
+ XCTAssertEqual(stream3.size(), 27U);
|
||||
+
|
||||
+ std::stringstream input("Lorem ipsum dolor sit amet");
|
||||
+ ANTLRInputStream stream4(input);
|
||||
+ std::string content = stream4.toString();
|
||||
+ XCTAssertEqual(content, "Lorem ipsum dolor sit amet"); // Now as utf-8 string.
|
||||
+ XCTAssertEqual(stream4.index(), 0U);
|
||||
+ XCTAssertEqual(stream4.size(), 26U);
|
||||
+
|
||||
+ std::string longString(33333, 'a');
|
||||
+ input.str(longString);
|
||||
+ stream4.load(input);
|
||||
+ XCTAssertEqual(stream4.index(), 0U);
|
||||
+ XCTAssertEqual(stream4.size(), 33333U);
|
||||
+
|
||||
+ input.clear();
|
||||
+ stream4.load(input);
|
||||
+ XCTAssertEqual(stream4.size(), 0U);
|
||||
+}
|
||||
+
|
||||
+- (void)testANTLRInputStreamUse {
|
||||
+ std::string text(u8"🚧Lorem ipsum dolor sit amet🕶");
|
||||
+ std::u32string wtext = utf8_to_utf32(text.c_str(), text.c_str() + text.size()); // Convert to UTF-32.
|
||||
+ ANTLRInputStream stream(text);
|
||||
+ XCTAssertEqual(stream.index(), 0U);
|
||||
+ XCTAssertEqual(stream.size(), wtext.size());
|
||||
+
|
||||
+ for (size_t i = 0; i < stream.size(); ++i) {
|
||||
+ stream.consume();
|
||||
+ XCTAssertEqual(stream.index(), i + 1);
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ stream.consume();
|
||||
+ XCTFail();
|
||||
+ } catch (IllegalStateException &e) {
|
||||
+ // Expected.
|
||||
+ std::string message = e.what();
|
||||
+ XCTAssertEqual(message, "cannot consume EOF");
|
||||
+ }
|
||||
+
|
||||
+ XCTAssertEqual(stream.index(), wtext.size());
|
||||
+ stream.reset();
|
||||
+ XCTAssertEqual(stream.index(), 0U);
|
||||
+
|
||||
+ XCTAssertEqual(stream.LA(0), 0ULL);
|
||||
+ for (size_t i = 1; i < wtext.size(); ++i) {
|
||||
+ XCTAssertEqual(stream.LA(static_cast<ssize_t>(i)), wtext[i - 1]); // LA(1) means: current char.
|
||||
+ XCTAssertEqual(stream.LT(static_cast<ssize_t>(i)), wtext[i - 1]); // LT is mapped to LA.
|
||||
+ XCTAssertEqual(stream.index(), 0U); // No consumption when looking ahead.
|
||||
+ }
|
||||
+
|
||||
+ stream.seek(wtext.size() - 1);
|
||||
+ XCTAssertEqual(stream.index(), wtext.size() - 1);
|
||||
+
|
||||
+ stream.seek(wtext.size() / 2);
|
||||
+ XCTAssertEqual(stream.index(), wtext.size() / 2);
|
||||
+
|
||||
+ stream.seek(wtext.size() - 1);
|
||||
+ for (ssize_t i = 1; i < static_cast<ssize_t>(wtext.size()) - 1; ++i) {
|
||||
+ XCTAssertEqual(stream.LA(-i), wtext[wtext.size() - i - 1]); // LA(-1) means: previous char.
|
||||
+ XCTAssertEqual(stream.LT(-i), wtext[wtext.size() - i - 1]); // LT is mapped to LA.
|
||||
+ XCTAssertEqual(stream.index(), wtext.size() - 1); // No consumption when looking ahead.
|
||||
+ }
|
||||
+
|
||||
+ XCTAssertEqual(stream.LA(-10000), IntStream::EOF);
|
||||
+
|
||||
+ // Mark and release do nothing.
|
||||
+ stream.reset();
|
||||
+ XCTAssertEqual(stream.index(), 0U);
|
||||
+ ssize_t marker = stream.mark();
|
||||
+ XCTAssertEqual(marker, -1);
|
||||
+ stream.seek(10);
|
||||
+ XCTAssertEqual(stream.index(), 10U);
|
||||
+ XCTAssertEqual(stream.mark(), -1);
|
||||
+
|
||||
+ stream.release(marker);
|
||||
+ XCTAssertEqual(stream.index(), 10U);
|
||||
+
|
||||
+ misc::Interval interval1(2, 10UL); // From - to, inclusive.
|
||||
+ std::string output = stream.getText(interval1);
|
||||
+ std::string sub = utf32_to_utf8(wtext.substr(2, 9));
|
||||
+ XCTAssertEqual(output, sub);
|
||||
+
|
||||
+ misc::Interval interval2(200, 10UL); // Start beyond bounds.
|
||||
+ output = stream.getText(interval2);
|
||||
+ XCTAssert(output.empty());
|
||||
+
|
||||
+ misc::Interval interval3(0, 200UL); // End beyond bounds.
|
||||
+ output = stream.getText(interval3);
|
||||
+ XCTAssertEqual(output, text);
|
||||
+
|
||||
+ stream.name = "unit tests"; // Quite useless test, as "name" is a public field.
|
||||
+ XCTAssertEqual(stream.getSourceName(), "unit tests");
|
||||
+}
|
||||
+
|
||||
+- (void)testUnbufferedTokenSteam {
|
||||
+ //UnbufferedTokenStream stream;
|
||||
+}
|
||||
+
|
||||
+@end
|
||||
--- /dev/null
|
||||
+++ third_party/antlr4/runtime/Cpp/demo/Mac/antlrcpp Tests/MiscClassTests.mm
|
||||
@@ -0,0 +1,388 @@
|
||||
+/*
|
||||
+ * [The "BSD license"]
|
||||
+ * Copyright (c) 2016 Mike Lischke
|
||||
+ * All rights reserved.
|
||||
+ *
|
||||
+ * Redistribution and use in source and binary forms, with or without
|
||||
+ * modification, are permitted provided that the following conditions
|
||||
+ * are met:
|
||||
+ *
|
||||
+ * 1. Redistributions of source code must retain the above copyright
|
||||
+ * notice, this list of conditions and the following disclaimer.
|
||||
+ * 2. Redistributions in binary form must reproduce the above copyright
|
||||
+ * notice, this list of conditions and the following disclaimer in the
|
||||
+ * documentation and/or other materials provided with the distribution.
|
||||
+ * 3. The name of the author may not be used to endorse or promote products
|
||||
+ * derived from this software without specific prior written permission.
|
||||
+ *
|
||||
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+ */
|
||||
+
|
||||
+#import <XCTest/XCTest.h>
|
||||
+
|
||||
+#include "antlr4-runtime.h"
|
||||
+
|
||||
+using namespace antlr4;
|
||||
+using namespace antlr4::misc;
|
||||
+using namespace antlrcpp;
|
||||
+
|
||||
+@interface MiscClassTests : XCTestCase
|
||||
+
|
||||
+@end
|
||||
+
|
||||
+@implementation MiscClassTests
|
||||
+
|
||||
+- (void)setUp {
|
||||
+ [super setUp];
|
||||
+ // Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
+}
|
||||
+
|
||||
+- (void)tearDown {
|
||||
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
+ [super tearDown];
|
||||
+}
|
||||
+
|
||||
+- (void)testCPPUtils {
|
||||
+
|
||||
+ class A { public: virtual ~A() {}; };
|
||||
+ class B : public A { public: virtual ~B() {}; };
|
||||
+ class C : public A { public: virtual ~C() {}; };
|
||||
+ class D : public C { public: virtual ~D() {}; };
|
||||
+
|
||||
+ {
|
||||
+ A *a = new A(); B *b = new B(); C *c = new C(); D *d = new D();
|
||||
+ XCTAssert(is<A*>(b));
|
||||
+ XCTAssertFalse(is<B*>(a));
|
||||
+ XCTAssert(is<A*>(c));
|
||||
+ XCTAssertFalse(is<B*>(c));
|
||||
+ XCTAssert(is<A*>(d));
|
||||
+ XCTAssert(is<C*>(d));
|
||||
+ XCTAssertFalse(is<B*>(d));
|
||||
+ delete a; delete b; delete c; delete d;
|
||||
+ }
|
||||
+ {
|
||||
+ Ref<A> a(new A());
|
||||
+ Ref<B> b(new B());
|
||||
+ Ref<C> c(new C());
|
||||
+ Ref<D> d(new D());
|
||||
+ XCTAssert(is<A>(b));
|
||||
+ XCTAssertFalse(is<B>(a));
|
||||
+ XCTAssert(is<A>(c));
|
||||
+ XCTAssertFalse(is<B>(c));
|
||||
+ XCTAssert(is<A>(d));
|
||||
+ XCTAssert(is<C>(d));
|
||||
+ XCTAssertFalse(is<B>(d));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+- (void)testMurmurHash {
|
||||
+ XCTAssertEqual(MurmurHash::initialize(), 0U);
|
||||
+ XCTAssertEqual(MurmurHash::initialize(31), 31U);
|
||||
+
|
||||
+ // In absence of real test vectors (64bit) for murmurhash I instead check if I can find duplicate hash values
|
||||
+ // in a deterministic and a random sequence of 100K values each.
|
||||
+ std::set<size_t> hashs;
|
||||
+ for (size_t i = 0; i < 100000; ++i) {
|
||||
+ std::vector<size_t> data = { i, static_cast<size_t>(i * M_PI), arc4random() };
|
||||
+ size_t hash = 0;
|
||||
+ for (auto value : data)
|
||||
+ hash = MurmurHash::update(hash, value);
|
||||
+ hash = MurmurHash::finish(hash, data.size());
|
||||
+ hashs.insert(hash);
|
||||
+ }
|
||||
+ XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
|
||||
+
|
||||
+ hashs.clear();
|
||||
+ for (size_t i = 0; i < 100000; ++i) {
|
||||
+ std::vector<size_t> data = { i, static_cast<size_t>(i * M_PI) };
|
||||
+ size_t hash = 0;
|
||||
+ for (auto value : data)
|
||||
+ hash = MurmurHash::update(hash, value);
|
||||
+ hash = MurmurHash::finish(hash, data.size());
|
||||
+ hashs.insert(hash);
|
||||
+ }
|
||||
+ XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
|
||||
+
|
||||
+ // Another test with fixed input but varying seeds.
|
||||
+ // Note: the higher the seed the less LSDs are in the result (for small input data).
|
||||
+ hashs.clear();
|
||||
+ std::vector<size_t> data = { L'µ', 'a', '@', '1' };
|
||||
+ for (size_t i = 0; i < 100000; ++i) {
|
||||
+ size_t hash = i;
|
||||
+ for (auto value : data)
|
||||
+ hash = MurmurHash::update(hash, value);
|
||||
+ hash = MurmurHash::finish(hash, data.size());
|
||||
+ hashs.insert(hash);
|
||||
+ }
|
||||
+ XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
|
||||
+}
|
||||
+
|
||||
+- (void)testInterval {
|
||||
+ // The Interval class contains no error handling (checks for invalid intervals), hence some of the results
|
||||
+ // look strange as we test of course such intervals as well.
|
||||
+ XCTAssertEqual(Interval().length(), 0UL);
|
||||
+ XCTAssertEqual(Interval(0, 0UL).length(), 1UL); // Remember: it's an inclusive interval.
|
||||
+ XCTAssertEqual(Interval(100, 100UL).length(), 1UL);
|
||||
+ XCTAssertEqual(Interval(-1L, -1).length(), 1UL); // Unwanted behavior: negative ranges.
|
||||
+ XCTAssertEqual(Interval(-1L, -2).length(), 0UL);
|
||||
+ XCTAssertEqual(Interval(100, 50UL).length(), 0UL);
|
||||
+
|
||||
+ XCTAssert(Interval() == Interval(-1L, -2));
|
||||
+ XCTAssert(Interval(0, 0UL) == Interval(0, 0UL));
|
||||
+ XCTAssertFalse(Interval(0, 1UL) == Interval(1, 2UL));
|
||||
+
|
||||
+ XCTAssertEqual(Interval().hashCode(), 22070U);
|
||||
+ XCTAssertEqual(Interval(0, 0UL).hashCode(), 22103U);
|
||||
+ XCTAssertEqual(Interval(10, 2000UL).hashCode(), 24413U);
|
||||
+
|
||||
+ // Results for the interval test functions in this order:
|
||||
+ // startsBeforeDisjoint
|
||||
+ // startsBeforeNonDisjoint
|
||||
+ // startsAfter
|
||||
+ // startsAfterDisjoint
|
||||
+ // startsAfterNonDisjoint
|
||||
+ // disjoint
|
||||
+ // adjacent
|
||||
+ // properlyContains
|
||||
+
|
||||
+ typedef std::vector<bool> TestResults;
|
||||
+ struct TestEntry { size_t runningNumber; Interval interval1, interval2; TestResults results; };
|
||||
+ std::vector<TestEntry> testData = {
|
||||
+ // Extreme cases + invalid intervals.
|
||||
+ { 0, Interval(), Interval(10, 20UL), { true, false, false, false, false, true, false, false } },
|
||||
+ { 1, Interval(1, 1UL), Interval(1, 1UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 2, Interval(10000, 10000UL), Interval(10000, 10000UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 3, Interval(100, 10UL), Interval(100, 10UL), { false, false, false, true, false, true, false, true } },
|
||||
+ { 4, Interval(100, 10UL), Interval(10, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 5, Interval(10, 100UL), Interval(100, 10UL), { false, true, false, false, false, false, false, true } },
|
||||
+
|
||||
+ // First starts before second. End varies.
|
||||
+ { 20, Interval(10, 12UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 21, Interval(10, 12UL), Interval(13, 100UL), { true, false, false, false, false, true, true, false } },
|
||||
+ { 22, Interval(10, 12UL), Interval(14, 100UL), { true, false, false, false, false, true, false, false } },
|
||||
+ { 23, Interval(10, 13UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 24, Interval(10, 14UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 25, Interval(10, 99UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 26, Interval(10, 100UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 27, Interval(10, 101UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 28, Interval(10, 1000UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+
|
||||
+ // First and second start equal. End varies.
|
||||
+ { 30, Interval(12, 12UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 31, Interval(12, 12UL), Interval(13, 100UL), { true, false, false, false, false, true, true, false } },
|
||||
+ { 32, Interval(12, 12UL), Interval(14, 100UL), { true, false, false, false, false, true, false, false } },
|
||||
+ { 33, Interval(12, 13UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 34, Interval(12, 14UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 35, Interval(12, 99UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 36, Interval(12, 100UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 37, Interval(12, 101UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 38, Interval(12, 1000UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+
|
||||
+ // First starts after second. End varies.
|
||||
+ { 40, Interval(15, 12UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 41, Interval(15, 12UL), Interval(13, 100UL), { false, false, true, false, true, false, true, false } },
|
||||
+ { 42, Interval(15, 12UL), Interval(14, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 43, Interval(15, 13UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 44, Interval(15, 14UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 45, Interval(15, 99UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 46, Interval(15, 100UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 47, Interval(15, 101UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 48, Interval(15, 1000UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+
|
||||
+ // First ends before second. Start varies.
|
||||
+ { 50, Interval(10, 90UL), Interval(20, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 51, Interval(19, 90UL), Interval(20, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 52, Interval(20, 90UL), Interval(20, 100UL), { false, true, false, false, false, false, false, false } },
|
||||
+ { 53, Interval(21, 90UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 54, Interval(98, 90UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 55, Interval(99, 90UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 56, Interval(100, 90UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 57, Interval(101, 90UL), Interval(20, 100UL), { false, false, true, true, false, true, true, false } },
|
||||
+ { 58, Interval(1000, 90UL), Interval(20, 100UL), { false, false, true, true, false, true, false, false } },
|
||||
+
|
||||
+ // First and second end equal. Start varies.
|
||||
+ { 60, Interval(10, 100UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 61, Interval(19, 100UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 62, Interval(20, 100UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 63, Interval(21, 100UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 64, Interval(98, 100UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 65, Interval(99, 100UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 66, Interval(100, 100UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 67, Interval(101, 100UL), Interval(20, 100UL), { false, false, true, true, false, true, true, false } },
|
||||
+ { 68, Interval(1000, 100UL), Interval(20, 100UL), { false, false, true, true, false, true, false, false } },
|
||||
+
|
||||
+ // First ends after second. Start varies.
|
||||
+ { 70, Interval(10, 1000UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 71, Interval(19, 1000UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 72, Interval(20, 1000UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
|
||||
+ { 73, Interval(21, 1000UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 74, Interval(98, 1000UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 75, Interval(99, 1000UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 76, Interval(100, 1000UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
|
||||
+ { 77, Interval(101, 1000UL), Interval(20, 100UL), { false, false, true, true, false, true, true, false } },
|
||||
+ { 78, Interval(1000, 1000UL), Interval(20, 100UL), { false, false, true, true, false, true, false, false } },
|
||||
+
|
||||
+ // It's possible to add more tests with borders that touch each other (e.g. first starts before/on/after second
|
||||
+ // and first ends directly before/after second. However, such cases are not handled differently in the Interval
|
||||
+ // class
|
||||
+ // (only adjacent intervals, where first ends directly before second starts and vice versa. So I ommitted them here.
|
||||
+ };
|
||||
+
|
||||
+ for (auto &entry : testData) {
|
||||
+ XCTAssert(entry.interval1.startsBeforeDisjoint(entry.interval2) == entry.results[0], @"entry: %zu",
|
||||
+ entry.runningNumber);
|
||||
+ XCTAssert(entry.interval1.startsBeforeNonDisjoint(entry.interval2) == entry.results[1], @"entry: %zu",
|
||||
+ entry.runningNumber);
|
||||
+ XCTAssert(entry.interval1.startsAfter(entry.interval2) == entry.results[2], @"entry: %zu", entry.runningNumber);
|
||||
+ XCTAssert(entry.interval1.startsAfterDisjoint(entry.interval2) == entry.results[3], @"entry: %zu",
|
||||
+ entry.runningNumber);
|
||||
+ XCTAssert(entry.interval1.startsAfterNonDisjoint(entry.interval2) == entry.results[4], @"entry: %zu",
|
||||
+ entry.runningNumber);
|
||||
+ XCTAssert(entry.interval1.disjoint(entry.interval2) == entry.results[5], @"entry: %zu", entry.runningNumber);
|
||||
+ XCTAssert(entry.interval1.adjacent(entry.interval2) == entry.results[6], @"entry: %zu", entry.runningNumber);
|
||||
+ XCTAssert(entry.interval1.properlyContains(entry.interval2) == entry.results[7], @"entry: %zu",
|
||||
+ entry.runningNumber);
|
||||
+ }
|
||||
+
|
||||
+ XCTAssert(Interval().Union(Interval(10, 100UL)) == Interval(-1L, 100));
|
||||
+ XCTAssert(Interval(10, 10UL).Union(Interval(10, 100UL)) == Interval(10, 100UL));
|
||||
+ XCTAssert(Interval(10, 11UL).Union(Interval(10, 100UL)) == Interval(10, 100UL));
|
||||
+ XCTAssert(Interval(10, 1000UL).Union(Interval(10, 100UL)) == Interval(10, 1000UL));
|
||||
+ XCTAssert(Interval(1000, 30UL).Union(Interval(10, 100UL)) == Interval(10, 100UL));
|
||||
+ XCTAssert(Interval(1000, 2000UL).Union(Interval(10, 100UL)) == Interval(10, 2000UL));
|
||||
+ XCTAssert(Interval(500, 2000UL).Union(Interval(10, 1000UL)) == Interval(10, 2000UL));
|
||||
+
|
||||
+ XCTAssert(Interval().intersection(Interval(10, 100UL)) == Interval(10, -2L));
|
||||
+ XCTAssert(Interval(10, 10UL).intersection(Interval(10, 100UL)) == Interval(10, 10UL));
|
||||
+ XCTAssert(Interval(10, 11UL).intersection(Interval(10, 100UL)) == Interval(10, 11UL));
|
||||
+ XCTAssert(Interval(10, 1000UL).intersection(Interval(10, 100UL)) == Interval(10, 100UL));
|
||||
+ XCTAssert(Interval(1000, 30UL).intersection(Interval(10, 100UL)) == Interval(1000, 30UL));
|
||||
+ XCTAssert(Interval(1000, 2000UL).intersection(Interval(10, 100UL)) == Interval(1000, 100UL));
|
||||
+ XCTAssert(Interval(500, 2000UL).intersection(Interval(10, 1000UL)) == Interval(500, 1000UL));
|
||||
+
|
||||
+ XCTAssert(Interval().toString() == "-1..-2");
|
||||
+ XCTAssert(Interval(10, 10UL).toString() == "10..10");
|
||||
+ XCTAssert(Interval(1000, 2000UL).toString() == "1000..2000");
|
||||
+ XCTAssert(Interval(500UL, INT_MAX).toString() == "500.." + std::to_string(INT_MAX));
|
||||
+}
|
||||
+
|
||||
+- (void)testIntervalSet {
|
||||
+ XCTAssertFalse(IntervalSet().isReadOnly());
|
||||
+ XCTAssert(IntervalSet().isEmpty());
|
||||
+
|
||||
+ IntervalSet set1;
|
||||
+ set1.setReadOnly(true);
|
||||
+ XCTAssert(set1.isReadOnly());
|
||||
+
|
||||
+ XCTAssert(IntervalSet() == IntervalSet::EMPTY_SET);
|
||||
+
|
||||
+ std::vector<Interval> intervals = { Interval(), Interval(10, 20UL), Interval(20, 100UL), Interval(1000, 2000UL) };
|
||||
+ IntervalSet set2(intervals);
|
||||
+ XCTAssertFalse(set2.isEmpty());
|
||||
+ XCTAssertFalse(set2.contains(9UL));
|
||||
+ XCTAssert(set2.contains(10UL));
|
||||
+ XCTAssert(set2.contains(20UL));
|
||||
+ XCTAssertTrue(set2.contains(22UL));
|
||||
+ XCTAssert(set2.contains(1111UL));
|
||||
+ XCTAssertFalse(set2.contains(10000UL));
|
||||
+ XCTAssertEqual(set2.getSingleElement(), Token::INVALID_TYPE);
|
||||
+ XCTAssertEqual(set2.getMinElement(), -1);
|
||||
+ XCTAssertEqual(set2.getMaxElement(), 2000);
|
||||
+
|
||||
+ IntervalSet set3(set2);
|
||||
+ XCTAssertFalse(set3.isEmpty());
|
||||
+ XCTAssertFalse(set3.contains(9UL));
|
||||
+ XCTAssert(set3.contains(10UL));
|
||||
+ XCTAssert(set3.contains(20UL));
|
||||
+ XCTAssertTrue(set3.contains(22UL));
|
||||
+ XCTAssert(set3.contains(1111UL));
|
||||
+ XCTAssertFalse(set3.contains(10000UL));
|
||||
+ XCTAssertEqual(set3.getSingleElement(), Token::INVALID_TYPE);
|
||||
+ XCTAssertEqual(set3.getMinElement(), 10);
|
||||
+ XCTAssertEqual(set3.getMaxElement(), 2000);
|
||||
+
|
||||
+ set3.add(Interval(100, 1000UL));
|
||||
+ XCTAssertEqual(set3.getMinElement(), 10);
|
||||
+ set3.add(Interval(9, 1000UL));
|
||||
+ XCTAssertEqual(set3.getMinElement(), 9);
|
||||
+ set3.add(Interval(1, 1UL));
|
||||
+ XCTAssertEqual(set3.getMinElement(), 1);
|
||||
+
|
||||
+ IntervalSet set4;
|
||||
+ set4.add(10);
|
||||
+ XCTAssertEqual(set4.getSingleElement(), 10);
|
||||
+ XCTAssertEqual(set4.getMinElement(), 10);
|
||||
+ XCTAssertEqual(set4.getMaxElement(), 10);
|
||||
+
|
||||
+ set4.clear();
|
||||
+ XCTAssert(set4.isEmpty());
|
||||
+ set4.add(Interval(10, 10UL));
|
||||
+ XCTAssertEqual(set4.getSingleElement(), 10);
|
||||
+ XCTAssertEqual(set4.getMinElement(), 10);
|
||||
+ XCTAssertEqual(set4.getMaxElement(), 10);
|
||||
+ set4.setReadOnly(true);
|
||||
+ try {
|
||||
+ set4.clear();
|
||||
+ XCTFail(@"Expected exception");
|
||||
+ } catch (IllegalStateException &e) {
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ set4.setReadOnly(false);
|
||||
+ XCTFail(@"Expected exception");
|
||||
+ } catch (IllegalStateException &e) {
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ set4 = IntervalSet::of(12345);
|
||||
+ XCTFail(@"Expected exception");
|
||||
+ } catch (IllegalStateException &e) {
|
||||
+ }
|
||||
+
|
||||
+ IntervalSet set5 = IntervalSet::of(12345);
|
||||
+ XCTAssertEqual(set5.getSingleElement(), 12345);
|
||||
+ XCTAssertEqual(set5.getMinElement(), 12345);
|
||||
+ XCTAssertEqual(set5.getMaxElement(), 12345);
|
||||
+
|
||||
+ IntervalSet set6(10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50);
|
||||
+ XCTAssertEqual(set6.getMinElement(), 5);
|
||||
+ XCTAssertEqual(set6.getMaxElement(), 50);
|
||||
+ XCTAssertEqual(set6.size(), 10U);
|
||||
+ set6.add(12, 18);
|
||||
+ XCTAssertEqual(set6.size(), 16U); // (15, 15) replaced by (12, 18)
|
||||
+ set6.add(9, 33);
|
||||
+ XCTAssertEqual(set6.size(), 30U); // (10, 10), (12, 18), (20, 20), (25, 25) and (30, 30) replaced by (9, 33)
|
||||
+
|
||||
+ XCTAssert(IntervalSet(3, 1, 2, 10).Or(IntervalSet(3, 1, 2, 5)) == IntervalSet(4, 1, 2, 5, 10));
|
||||
+ XCTAssert(IntervalSet({ Interval(2, 10UL) }).Or(IntervalSet({ Interval(5, 8UL) })) == IntervalSet({ Interval(2, 10UL) }));
|
||||
+
|
||||
+ XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(7, 55)) == IntervalSet::of(11, 55));
|
||||
+ XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(20, 55)) == IntervalSet::of(20, 55));
|
||||
+ XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(5, 6)) == IntervalSet::EMPTY_SET);
|
||||
+ XCTAssert(IntervalSet::of(15, 20).complement(IntervalSet::of(7, 55)) ==
|
||||
+ IntervalSet({ Interval(7, 14UL), Interval(21, 55UL) }));
|
||||
+ XCTAssert(IntervalSet({ Interval(1, 10UL), Interval(30, 35UL) }).complement(IntervalSet::of(7, 55)) ==
|
||||
+ IntervalSet({ Interval(11, 29UL), Interval(36, 55UL) }));
|
||||
+
|
||||
+ XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(7, 55)) == IntervalSet::of(7, 10));
|
||||
+ XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(20, 55)) == IntervalSet::EMPTY_SET);
|
||||
+ XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(5, 6)) == IntervalSet::of(5, 6));
|
||||
+ XCTAssert(IntervalSet::of(15, 20).And(IntervalSet::of(7, 55)) == IntervalSet::of(15, 20));
|
||||
+
|
||||
+ XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(7, 55)) == IntervalSet::of(1, 6));
|
||||
+ XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(20, 55)) == IntervalSet::of(1, 10));
|
||||
+ XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(5, 6)) ==
|
||||
+ IntervalSet({ Interval(1, 4UL), Interval(7, 10UL) }));
|
||||
+ XCTAssert(IntervalSet::of(15, 20).subtract(IntervalSet::of(7, 55)) == IntervalSet::EMPTY_SET);
|
||||
+}
|
||||
+
|
||||
+@end
|
43
third_party/antlr4/runtime/Cpp/demo/Mac/build.sh
vendored
43
third_party/antlr4/runtime/Cpp/demo/Mac/build.sh
vendored
@ -1,43 +0,0 @@
|
||||
#!/bin/sh
|
||||
# [The "BSD license"]
|
||||
# Copyright (c) 2013 Terence Parr
|
||||
# Copyright (c) 2013 Dan McLaughlin
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
ANTLRCPP_XCODEPROJ="${CURRENT_DIR}/antlrcpp.xcodeproj"
|
||||
|
||||
# OS X
|
||||
xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp -configuration Release $@
|
||||
xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp -configuration Debug $@
|
||||
|
||||
# iOS
|
||||
#xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp_iphone -configuration Release -sdk iphoneos $@
|
||||
#xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp_iphone -configuration Debug -sdk iphoneos $@
|
||||
#xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp_iphone_sim -configuration Release -sdk iphonesimulator $@
|
||||
#xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp_iphone_sim -configuration Debug -sdk iphonesimulator $@
|
||||
|
13
third_party/antlr4/runtime/Cpp/demo/README.md
vendored
13
third_party/antlr4/runtime/Cpp/demo/README.md
vendored
@ -1,13 +0,0 @@
|
||||
## Demo application for the ANTLR 4 C++ target
|
||||
|
||||
This demo app shows how to build the ANTLR runtime both as dynamic and static library and how to use a parser generated from a simple demo grammar.
|
||||
|
||||
A few steps are necessary to get this to work:
|
||||
|
||||
- Download the current ANTLR jar and place it in this folder.
|
||||
- Open the generation script for your platform (generate.cmd for Windows, generate.sh for *nix/OSX) and update the LOCATION var to the actual name of the jar you downloaded.
|
||||
- Run the generation script. This will generate a test parser + lexer, along with listener + visitor classes in a subfolder named "generated". This is where the demo application looks for these files.
|
||||
- Open the project in the folder that matches your system.
|
||||
- Compile and run.
|
||||
|
||||
Compilation is done as described in the [runtime/cpp/readme.md](../README.md) file.
|
86
third_party/antlr4/runtime/Cpp/demo/TLexer.g4
vendored
86
third_party/antlr4/runtime/Cpp/demo/TLexer.g4
vendored
@ -1,86 +0,0 @@
|
||||
lexer grammar TLexer;
|
||||
|
||||
// These are all supported lexer sections:
|
||||
|
||||
// Lexer file header. Appears at the top of h + cpp files. Use e.g. for copyrights.
|
||||
@lexer::header {/* lexer header section */}
|
||||
|
||||
// Appears before any #include in h + cpp files.
|
||||
@lexer::preinclude {/* lexer precinclude section */}
|
||||
|
||||
// Follows directly after the standard #includes in h + cpp files.
|
||||
@lexer::postinclude {
|
||||
/* lexer postinclude section */
|
||||
#ifndef _WIN32
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
}
|
||||
|
||||
// Directly preceds the lexer class declaration in the h file (e.g. for additional types etc.).
|
||||
@lexer::context {/* lexer context section */}
|
||||
|
||||
// Appears in the public part of the lexer in the h file.
|
||||
@lexer::members {/* public lexer declarations section */
|
||||
bool canTestFoo() { return true; }
|
||||
bool isItFoo() { return true; }
|
||||
bool isItBar() { return true; }
|
||||
|
||||
void myFooLexerAction() { /* do something*/ };
|
||||
void myBarLexerAction() { /* do something*/ };
|
||||
}
|
||||
|
||||
// Appears in the private part of the lexer in the h file.
|
||||
@lexer::declarations {/* private lexer declarations/members section */}
|
||||
|
||||
// Appears in line with the other class member definitions in the cpp file.
|
||||
@lexer::definitions {/* lexer definitions section */}
|
||||
|
||||
channels { CommentsChannel, DirectiveChannel }
|
||||
|
||||
tokens {
|
||||
DUMMY
|
||||
}
|
||||
|
||||
Return: 'return';
|
||||
Continue: 'continue';
|
||||
|
||||
INT: Digit+;
|
||||
Digit: [0-9];
|
||||
|
||||
ID: LETTER (LETTER | '0'..'9')*;
|
||||
fragment LETTER : [a-zA-Z\u0080-\u{10FFFF}];
|
||||
|
||||
LessThan: '<';
|
||||
GreaterThan: '>';
|
||||
Equal: '=';
|
||||
And: 'and';
|
||||
|
||||
Colon: ':';
|
||||
Semicolon: ';';
|
||||
Plus: '+';
|
||||
Minus: '-';
|
||||
Star: '*';
|
||||
OpenPar: '(';
|
||||
ClosePar: ')';
|
||||
OpenCurly: '{' -> pushMode(Mode1);
|
||||
CloseCurly: '}' -> popMode;
|
||||
QuestionMark: '?';
|
||||
Comma: ',' -> skip;
|
||||
Dollar: '$' -> more, mode(Mode1);
|
||||
Ampersand: '&' -> type(DUMMY);
|
||||
|
||||
String: '"' .*? '"';
|
||||
Foo: {canTestFoo()}? 'foo' {isItFoo()}? { myFooLexerAction(); };
|
||||
Bar: 'bar' {isItBar()}? { myBarLexerAction(); };
|
||||
Any: Foo Dot Bar? DotDot Baz;
|
||||
|
||||
Comment : '#' ~[\r\n]* '\r'? '\n' -> channel(CommentsChannel);
|
||||
WS: [ \t\r\n]+ -> channel(99);
|
||||
|
||||
fragment Baz: 'Baz';
|
||||
|
||||
mode Mode1;
|
||||
Dot: '.';
|
||||
|
||||
mode Mode2;
|
||||
DotDot: '..';
|
119
third_party/antlr4/runtime/Cpp/demo/TParser.g4
vendored
119
third_party/antlr4/runtime/Cpp/demo/TParser.g4
vendored
@ -1,119 +0,0 @@
|
||||
parser grammar TParser;
|
||||
|
||||
options {
|
||||
tokenVocab = TLexer;
|
||||
}
|
||||
|
||||
// These are all supported parser sections:
|
||||
|
||||
// Parser file header. Appears at the top in all parser related files. Use e.g. for copyrights.
|
||||
@parser::header {/* parser/listener/visitor header section */}
|
||||
|
||||
// Appears before any #include in h + cpp files.
|
||||
@parser::preinclude {/* parser precinclude section */}
|
||||
|
||||
// Follows directly after the standard #includes in h + cpp files.
|
||||
@parser::postinclude {
|
||||
/* parser postinclude section */
|
||||
#ifndef _WIN32
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
}
|
||||
|
||||
// Directly preceeds the parser class declaration in the h file (e.g. for additional types etc.).
|
||||
@parser::context {/* parser context section */}
|
||||
|
||||
// Appears in the private part of the parser in the h file.
|
||||
// The function bodies could also appear in the definitions section, but I want to maximize
|
||||
// Java compatibility, so we can also create a Java parser from this grammar.
|
||||
// Still, some tweaking is necessary after the Java file generation (e.g. bool -> boolean).
|
||||
@parser::members {
|
||||
/* public parser declarations/members section */
|
||||
bool myAction() { return true; }
|
||||
bool doesItBlend() { return true; }
|
||||
void cleanUp() {}
|
||||
void doInit() {}
|
||||
void doAfter() {}
|
||||
}
|
||||
|
||||
// Appears in the public part of the parser in the h file.
|
||||
@parser::declarations {/* private parser declarations section */}
|
||||
|
||||
// Appears in line with the other class member definitions in the cpp file.
|
||||
@parser::definitions {/* parser definitions section */}
|
||||
|
||||
// Additionally there are similar sections for (base)listener and (base)visitor files.
|
||||
@parser::listenerpreinclude {/* listener preinclude section */}
|
||||
@parser::listenerpostinclude {/* listener postinclude section */}
|
||||
@parser::listenerdeclarations {/* listener public declarations/members section */}
|
||||
@parser::listenermembers {/* listener private declarations/members section */}
|
||||
@parser::listenerdefinitions {/* listener definitions section */}
|
||||
|
||||
@parser::baselistenerpreinclude {/* base listener preinclude section */}
|
||||
@parser::baselistenerpostinclude {/* base listener postinclude section */}
|
||||
@parser::baselistenerdeclarations {/* base listener public declarations/members section */}
|
||||
@parser::baselistenermembers {/* base listener private declarations/members section */}
|
||||
@parser::baselistenerdefinitions {/* base listener definitions section */}
|
||||
|
||||
@parser::visitorpreinclude {/* visitor preinclude section */}
|
||||
@parser::visitorpostinclude {/* visitor postinclude section */}
|
||||
@parser::visitordeclarations {/* visitor public declarations/members section */}
|
||||
@parser::visitormembers {/* visitor private declarations/members section */}
|
||||
@parser::visitordefinitions {/* visitor definitions section */}
|
||||
|
||||
@parser::basevisitorpreinclude {/* base visitor preinclude section */}
|
||||
@parser::basevisitorpostinclude {/* base visitor postinclude section */}
|
||||
@parser::basevisitordeclarations {/* base visitor public declarations/members section */}
|
||||
@parser::basevisitormembers {/* base visitor private declarations/members section */}
|
||||
@parser::basevisitordefinitions {/* base visitor definitions section */}
|
||||
|
||||
// Actual grammar start.
|
||||
main: stat+ EOF;
|
||||
divide : ID (and_ GreaterThan)? {doesItBlend()}?;
|
||||
and_ @init{ doInit(); } @after { doAfter(); } : And ;
|
||||
|
||||
conquer:
|
||||
divide+
|
||||
| {doesItBlend()}? and_ { myAction(); }
|
||||
| ID (LessThan* divide)?? { $ID.text; }
|
||||
;
|
||||
|
||||
// Unused rule to demonstrate some of the special features.
|
||||
unused[double input = 111] returns [double calculated] locals [int _a, double _b, int _c] @init{ doInit(); } @after { doAfter(); } :
|
||||
stat
|
||||
;
|
||||
catch [...] {
|
||||
// Replaces the standard exception handling.
|
||||
}
|
||||
finally {
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
unused2:
|
||||
(unused[1] .)+ (Colon | Semicolon | Plus)? ~Semicolon
|
||||
;
|
||||
|
||||
stat: expr Equal expr Semicolon
|
||||
| expr Semicolon
|
||||
;
|
||||
|
||||
expr: expr Star expr
|
||||
| expr Plus expr
|
||||
| OpenPar expr ClosePar
|
||||
| <assoc = right> expr QuestionMark expr Colon expr
|
||||
| <assoc = right> expr Equal expr
|
||||
| identifier = id
|
||||
| flowControl
|
||||
| INT
|
||||
| String
|
||||
;
|
||||
|
||||
flowControl:
|
||||
Return expr # Return
|
||||
| Continue # Continue
|
||||
;
|
||||
|
||||
id: ID;
|
||||
array : OpenCurly el += INT (Comma el += INT)* CloseCurly;
|
||||
idarray : OpenCurly element += id (Comma element += id)* CloseCurly;
|
||||
any: t = .;
|
@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="generated">
|
||||
<UniqueIdentifier>{ef397b7b-1192-4d44-93ed-fadaec7622e8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\generated\TParser.cpp">
|
||||
<Filter>generated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\generated\TParserBaseListener.cpp">
|
||||
<Filter>generated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\generated\TParserBaseVisitor.cpp">
|
||||
<Filter>generated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\generated\TParserListener.cpp">
|
||||
<Filter>generated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\generated\TParserVisitor.cpp">
|
||||
<Filter>generated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\generated\TLexer.cpp">
|
||||
<Filter>generated</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\generated\TLexer.h">
|
||||
<Filter>generated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\generated\TParser.h">
|
||||
<Filter>generated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\generated\TParserBaseListener.h">
|
||||
<Filter>generated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\generated\TParserBaseVisitor.h">
|
||||
<Filter>generated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\generated\TParserListener.h">
|
||||
<Filter>generated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\generated\TParserVisitor.h">
|
||||
<Filter>generated</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,42 +0,0 @@
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
//
|
||||
// main.cpp
|
||||
// antlr4-cpp-demo
|
||||
//
|
||||
// Created by Mike Lischke on 13.03.16.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "TLexer.h"
|
||||
#include "TParser.h"
|
||||
#include "antlr4-runtime.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
using namespace antlrcpptest;
|
||||
using namespace antlr4;
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
ANTLRInputStream input(
|
||||
"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);");
|
||||
TLexer lexer(&input);
|
||||
CommonTokenStream tokens(&lexer);
|
||||
|
||||
TParser parser(&tokens);
|
||||
tree::ParseTree* tree = parser.main();
|
||||
|
||||
std::wstring s = antlrcpp::s2ws(tree->toStringTree(&parser)) + L"\n";
|
||||
|
||||
OutputDebugString(s.data()); // Only works properly since VS 2015.
|
||||
// std::wcout << "Parse Tree: " << s << std::endl; Unicode output in the
|
||||
// console is very limited.
|
||||
|
||||
return 0;
|
||||
}
|
13
third_party/antlr4/runtime/Cpp/demo/generate.cmd
vendored
13
third_party/antlr4/runtime/Cpp/demo/generate.cmd
vendored
@ -1,13 +0,0 @@
|
||||
@echo off
|
||||
:: Created 2016, Mike Lischke (public domain)
|
||||
|
||||
:: This script is used to generate source files from the test grammars in the same folder. The generated files are placed
|
||||
:: into a subfolder "generated" which the demo project uses to compile a demo binary.
|
||||
|
||||
:: Download the ANLTR jar and place it in the same folder as this script (or adjust the LOCATION var accordingly).
|
||||
|
||||
set LOCATION=antlr-4.7.1-complete.jar
|
||||
java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
|
||||
::java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
|
||||
::java -jar %LOCATION% -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
|
||||
|
28
third_party/antlr4/runtime/Cpp/demo/generate.sh
vendored
28
third_party/antlr4/runtime/Cpp/demo/generate.sh
vendored
@ -1,28 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o errexit
|
||||
|
||||
# Created 2016, Mike Lischke (public domain)
|
||||
|
||||
# This script is used to generate source files from the test grammars in the same folder. The generated files are placed
|
||||
# into a subfolder "generated" which the demo project uses to compile a demo binary.
|
||||
|
||||
# There are 2 ways of running the ANTLR generator here.
|
||||
|
||||
# 1) Running from jar. Use the given jar (or replace it by another one you built or downloaded) for generation.
|
||||
#LOCATION=antlr4-4.5.4-SNAPSHOT.jar
|
||||
#java -jar $LOCATION -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
|
||||
#java -jar $LOCATION -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
|
||||
#java -jar $LOCATION -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
|
||||
|
||||
# 2) Running from class path. This requires that you have both antlr3 and antlr4 compiled. In this scenario no installation
|
||||
# is needed. You just compile the java class files (using "mvn compile" in both the antlr4 and the antlr3 root folders).
|
||||
# The script then runs the generation using these class files, by specifying them on the classpath.
|
||||
# Also the string template jar is needed. Adjust CLASSPATH if you have stored the jar in a different folder as this script assumes.
|
||||
# Furthermore is assumed that the antlr3 folder is located side-by-side with the antlr4 folder. Adjust CLASSPATH if not.
|
||||
# This approach is especially useful if you are working on a target stg file, as it doesn't require to regenerate the
|
||||
# antlr jar over and over again.
|
||||
CLASSPATH=../../../tool/resources/:ST-4.0.8.jar:../../../tool/target/classes:../../../runtime/Java/target/classes:../../../../antlr3/runtime/Java/target/classes
|
||||
|
||||
java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
|
||||
#java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
|
||||
#java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Java -listener -visitor -o generated/ TLexer.g4 TParser.g4
|
27
third_party/antlr4/runtime/Cpp/deploy-macos.sh
vendored
27
third_party/antlr4/runtime/Cpp/deploy-macos.sh
vendored
@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Clean left overs from previous builds if there are any
|
||||
rm -f -R antlr4-runtime build lib 2> /dev/null
|
||||
rm antlr4-cpp-runtime-macos.zip 2> /dev/null
|
||||
|
||||
# Binaries
|
||||
xcodebuild -project runtime/antlrcpp.xcodeproj -target antlr4 -configuration Release
|
||||
xcodebuild -project runtime/antlrcpp.xcodeproj -target antlr4_static -configuration Release
|
||||
rm -f -R lib
|
||||
mkdir lib
|
||||
mv runtime/build/Release/libantlr4-runtime.a lib/
|
||||
mv runtime/build/Release/libantlr4-runtime.dylib lib/
|
||||
|
||||
# Headers
|
||||
rm -f -R antlr4-runtime
|
||||
pushd runtime/src
|
||||
find . -name '*.h' | cpio -pdm ../../antlr4-runtime
|
||||
popd
|
||||
|
||||
# Zip up and clean up
|
||||
zip -r antlr4-cpp-runtime-macos.zip antlr4-runtime lib
|
||||
|
||||
rm -f -R antlr4-runtime build lib
|
||||
|
||||
# Deploy
|
||||
#cp antlr4-cpp-runtime-macos.zip ~/antlr/sites/website-antlr4/download
|
14
third_party/antlr4/runtime/Cpp/deploy-source.sh
vendored
14
third_party/antlr4/runtime/Cpp/deploy-source.sh
vendored
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Zip it
|
||||
rm -f antlr4-cpp-runtime-source.zip
|
||||
zip -r antlr4-cpp-runtime-source.zip "README.md" "cmake" "demo" "runtime" "CMakeLists.txt" "deploy-macos.sh" "deploy-source.sh" "deploy-windows.cmd" "VERSION" \
|
||||
-X -x "*.DS_Store*" "antlrcpp.xcodeproj/xcuserdata/*" "*Build*" "*DerivedData*" "*.jar" "demo/generated/*" "*.vscode*" "runtime/build/*"
|
||||
|
||||
# Add the license file from the ANTLR root as well.
|
||||
pushd ../../
|
||||
zip runtime/cpp/antlr4-cpp-runtime-source.zip LICENSE.txt
|
||||
popd
|
||||
|
||||
# Deploy
|
||||
#cp antlr4-cpp-runtime-source.zip ~/antlr/sites/website-antlr4/download
|
@ -1,58 +0,0 @@
|
||||
@echo off
|
||||
|
||||
rem Clean left overs from previous builds if there are any
|
||||
if exist bin rmdir /S /Q runtime\bin
|
||||
if exist obj rmdir /S /Q runtime\obj
|
||||
if exist lib rmdir /S /Q lib
|
||||
if exist antlr4-runtime rmdir /S /Q antlr4-runtime
|
||||
if exist antlr4-cpp-runtime-vs2013.zip erase antlr4-cpp-runtime-vs2013.zip
|
||||
if exist antlr4-cpp-runtime-vs2015.zip erase antlr4-cpp-runtime-vs2015.zip
|
||||
|
||||
rem Headers
|
||||
xcopy runtime\src\*.h antlr4-runtime\ /s
|
||||
|
||||
rem Binaries
|
||||
rem VS 2013 disabled by default. Change the X to a C to enable it.
|
||||
if exist "X:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat" (
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"
|
||||
|
||||
pushd runtime
|
||||
msbuild antlr4cpp-vs2013.vcxproj /p:configuration="Release DLL" /p:platform=Win32
|
||||
msbuild antlr4cpp-vs2013.vcxproj /p:configuration="Release DLL" /p:platform=x64
|
||||
popd
|
||||
|
||||
7z a antlr4-cpp-runtime-vs2013.zip antlr4-runtime
|
||||
xcopy runtime\bin\*.dll lib\ /s
|
||||
xcopy runtime\bin\*.lib lib\ /s
|
||||
7z a antlr4-cpp-runtime-vs2013.zip lib
|
||||
|
||||
rmdir /S /Q lib
|
||||
rmdir /S /Q runtime\bin
|
||||
rmdir /S /Q runtime\obj
|
||||
|
||||
rem if exist antlr4-cpp-runtime-vs2013.zip copy antlr4-cpp-runtime-vs2013.zip ~/antlr/sites/website-antlr4/download
|
||||
)
|
||||
|
||||
if exist "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" (
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
|
||||
|
||||
pushd runtime
|
||||
msbuild antlr4cpp-vs2015.vcxproj /p:configuration="Release DLL" /p:platform=Win32
|
||||
msbuild antlr4cpp-vs2015.vcxproj /p:configuration="Release DLL" /p:platform=x64
|
||||
popd
|
||||
|
||||
7z a antlr4-cpp-runtime-vs2015.zip antlr4-runtime
|
||||
xcopy runtime\bin\*.dll lib\ /s
|
||||
xcopy runtime\bin\*.lib lib\ /s
|
||||
7z a antlr4-cpp-runtime-vs2015.zip lib
|
||||
|
||||
rmdir /S /Q lib
|
||||
rmdir /S /Q runtime\bin
|
||||
rmdir /S /Q runtime\obj
|
||||
|
||||
rem if exist antlr4-cpp-runtime-vs2015.zip copy antlr4-cpp-runtime-vs2015.zip ~/antlr/sites/website-antlr4/download
|
||||
)
|
||||
|
||||
rmdir /S /Q antlr4-runtime
|
||||
|
||||
:end
|
@ -1,111 +0,0 @@
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/runtime/src
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/atn
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/dfa
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/misc
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/support
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/tree
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/tree/pattern
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/tree/xpath
|
||||
)
|
||||
|
||||
|
||||
file(GLOB libantlrcpp_SRC
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/atn/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/dfa/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/misc/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/support/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/tree/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/tree/pattern/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/tree/xpath/*.cpp"
|
||||
)
|
||||
|
||||
add_library(antlr4_shared SHARED ${libantlrcpp_SRC})
|
||||
add_library(antlr4_static STATIC ${libantlrcpp_SRC})
|
||||
|
||||
set(LIB_OUTPUT_DIR "${CMAKE_HOME_DIRECTORY}/dist") # put generated libraries here.
|
||||
message(STATUS "Output libraries to ${LIB_OUTPUT_DIR}")
|
||||
|
||||
# make sure 'make' works fine even if ${LIB_OUTPUT_DIR} is deleted.
|
||||
add_custom_target(make_lib_output_dir ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_OUTPUT_DIR}
|
||||
)
|
||||
|
||||
add_dependencies(antlr4_shared make_lib_output_dir)
|
||||
add_dependencies(antlr4_static make_lib_output_dir)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
target_link_libraries(antlr4_shared ${UUID_LIBRARIES})
|
||||
target_link_libraries(antlr4_static ${UUID_LIBRARIES})
|
||||
elseif(APPLE)
|
||||
target_link_libraries(antlr4_shared ${COREFOUNDATION_LIBRARY})
|
||||
target_link_libraries(antlr4_static ${COREFOUNDATION_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(disabled_compile_warnings "/wd4251")
|
||||
else()
|
||||
set(disabled_compile_warnings "-Wno-overloaded-virtual")
|
||||
endif ()
|
||||
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(disabled_compile_warnings "${disabled_compile_warnings} -Wno-dollar-in-identifier-extension -Wno-four-char-constants")
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
|
||||
set(disabled_compile_warnings "${disabled_compile_warnings} -Wno-multichar")
|
||||
endif()
|
||||
|
||||
set(extra_share_compile_flags "")
|
||||
set(extra_static_compile_flags "")
|
||||
if (WIN32)
|
||||
set(extra_share_compile_flags "-DANTLR4CPP_EXPORTS")
|
||||
set(extra_static_compile_flags "-DANTLR4CPP_STATIC")
|
||||
endif(WIN32)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
target_compile_options(antlr4_shared PRIVATE "/MD$<$<CONFIG:Debug>:d>")
|
||||
target_compile_options(antlr4_static PRIVATE "/MT$<$<CONFIG:Debug>:d>")
|
||||
endif()
|
||||
|
||||
set(static_lib_suffix "")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(static_lib_suffix "-static")
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(extra_share_compile_flags "-DANTLR4CPP_EXPORTS -MP /wd4251")
|
||||
set(extra_static_compile_flags "-DANTLR4CPP_STATIC -MP")
|
||||
endif()
|
||||
|
||||
set_target_properties(antlr4_shared
|
||||
PROPERTIES VERSION ${ANTLR_VERSION}
|
||||
SOVERSION ${ANTLR_VERSION}
|
||||
OUTPUT_NAME antlr4-runtime
|
||||
LIBRARY_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
|
||||
# TODO: test in windows. DLL is treated as runtime.
|
||||
# see https://cmake.org/cmake/help/v3.0/prop_tgt/LIBRARY_OUTPUT_DIRECTORY.html
|
||||
RUNTIME_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
|
||||
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_share_compile_flags}")
|
||||
|
||||
set_target_properties(antlr4_static
|
||||
PROPERTIES VERSION ${ANTLR_VERSION}
|
||||
SOVERSION ${ANTLR_VERSION}
|
||||
OUTPUT_NAME "antlr4-runtime${static_lib_suffix}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
|
||||
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}")
|
||||
|
||||
install(TARGETS antlr4_shared
|
||||
DESTINATION lib)
|
||||
install(TARGETS antlr4_static
|
||||
ARCHIVE DESTINATION lib)
|
||||
|
||||
install(DIRECTORY "${PROJECT_SOURCE_DIR}/runtime/src/"
|
||||
DESTINATION "include/antlr4-runtime"
|
||||
COMPONENT dev
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
@ -1,17 +0,0 @@
|
||||
//
|
||||
// antlrcpp-ios.h
|
||||
// antlrcpp-ios
|
||||
//
|
||||
// Created by Mike Lischke on 05.05.16.
|
||||
// Copyright © 2016 Mike Lischke. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for antlrcpp-ios.
|
||||
FOUNDATION_EXPORT double antlrcpp_iosVersionNumber;
|
||||
|
||||
//! Project version string for antlrcpp-ios.
|
||||
FOUNDATION_EXPORT const unsigned char antlrcpp_iosVersionString[];
|
||||
|
||||
#include "antlr4-runtime.h"
|
Loading…
Reference in New Issue
Block a user