From: Mathias Preiner Date: Wed, 15 Aug 2018 00:43:17 +0000 (-0700) Subject: cmake: Generate token headers. X-Git-Tag: cvc5-1.0.0~4605 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=52b9d01f4c3cc0b34daa4759e1004fc315f3f30e;p=cvc5.git cmake: Generate token headers. --- diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index a66ab5a1e..023d02cbe 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -19,6 +19,7 @@ add_executable(cvc4-main ${cvc4main_src_files}) target_compile_definitions(cvc4-main PRIVATE -D__BUILDING_CVC4DRIVER) set_target_properties(cvc4-main PROPERTIES OUTPUT_NAME cvc4) target_link_libraries(cvc4-main main) +add_dependencies(cvc4-main token-headers) #set(pcvc4_src_files # main.cpp @@ -32,3 +33,44 @@ target_link_libraries(cvc4-main main) # command_executor_portfolio.h # driver_unified.cpp #) + +add_custom_command( + OUTPUT cvc_tokens.h + COMMAND + sh ${CMAKE_CURRENT_LIST_DIR}/gen-token-header.sh + ${CMAKE_CURRENT_LIST_DIR}/../parser/cvc/Cvc.g + ${CMAKE_CURRENT_BINARY_DIR}/cvc_tokens.h + DEPENDS ../parser/cvc/Cvc.g +) + +add_custom_command( + OUTPUT smt1_tokens.h + COMMAND + sh ${CMAKE_CURRENT_LIST_DIR}/gen-token-header.sh + ${CMAKE_CURRENT_LIST_DIR}/../parser/smt1/Smt1.g + ${CMAKE_CURRENT_BINARY_DIR}/smt1_tokens.h + DEPENDS ../parser/smt1/Smt1.g +) + +add_custom_command( + OUTPUT smt2_tokens.h + COMMAND + sh ${CMAKE_CURRENT_LIST_DIR}/gen-token-header.sh + ${CMAKE_CURRENT_LIST_DIR}/../parser/smt2/Smt2.g + ${CMAKE_CURRENT_BINARY_DIR}/smt2_tokens.h + DEPENDS ../parser/smt2/Smt2.g +) + +add_custom_command( + OUTPUT tptp_tokens.h + COMMAND + sh ${CMAKE_CURRENT_LIST_DIR}/gen-token-header.sh + ${CMAKE_CURRENT_LIST_DIR}/../parser/tptp/Tptp.g + ${CMAKE_CURRENT_BINARY_DIR}/tptp_tokens.h + DEPENDS ../parser/tptp/Tptp.g +) + +add_custom_target( + token-headers + DEPENDS cvc_tokens.h smt1_tokens.h smt2_tokens.h tptp_tokens.h +) diff --git a/src/main/gen-token-header.sh b/src/main/gen-token-header.sh new file mode 100644 index 000000000..86e30ae42 --- /dev/null +++ b/src/main/gen-token-header.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +grep "'[a-zA-Z][a-zA-Z0-9_-][a-zA-Z0-9_-]*'" "$1" | \ + sed 's/.*'\''\([a-zA-Z0-9_-]*\)'\''.*/"\1",/' | \ + sort -u > "$2"