Skip to content

Commit

Permalink
Use long re2c options and adjust the --conditions
Browse files Browse the repository at this point in the history
The --conditions option is available since re2c 1.1.
  • Loading branch information
petk committed Jan 1, 2025
1 parent f0f39a7 commit bfcbddd
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
21 changes: 13 additions & 8 deletions cmake/Zend/cmake/GenerateGrammar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ if(BISON_FOUND)
${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_parser.c
HEADER
${verbose}
CODEGEN
)

if(CMAKE_SCRIPT_MODE_FILE)
set(verbose "")
else()
set(verbose VERBOSE)
endif()

bison(
zend_language_parser
zend_language_parser.y
Expand Down Expand Up @@ -125,7 +120,12 @@ if(RE2C_FOUND)
zend_ini_scanner.l
${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_scanner.c
HEADER ${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_scanner_defs.h
OPTIONS --case-inverted -cbdF
OPTIONS
--case-inverted
--conditions
--bit-vectors
--debug-output
--flex-syntax
CODEGEN
)

Expand All @@ -134,7 +134,12 @@ if(RE2C_FOUND)
zend_language_scanner.l
${CMAKE_CURRENT_SOURCE_DIR}/zend_language_scanner.c
HEADER ${CMAKE_CURRENT_SOURCE_DIR}/zend_language_scanner_defs.h
OPTIONS --case-inverted -cbdF
OPTIONS
--case-inverted
--conditions
--bit-vectors
--debug-output
--flex-syntax
CODEGEN
)
endif()
13 changes: 13 additions & 0 deletions cmake/cmake/modules/FindRE2C.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,19 @@ function(_re2c_process_options options result)
list(PREPEND options ${RE2C_DEFAULT_OPTIONS})
endif()

# Remove any generator expressions when running in script mode.
if(CMAKE_SCRIPT_MODE_FILE)
list(TRANSFORM options GENEX_STRIP)
endif()

# Sync long -c variants. The long --conditions option was introduced in re2c
# version 1.1 as a new alias for the legacy --start-conditions.
if(RE2C_VERSION VERSION_LESS 1.1)
list(TRANSFORM options REPLACE "^--conditions$" "--start-conditions")
else()
list(TRANSFORM options REPLACE "^--start-conditions$" "--conditions")
endif()

set(${result} ${options})

return(PROPAGATE ${result})
Expand Down
6 changes: 3 additions & 3 deletions cmake/ext/json/cmake/GenerateGrammar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ if(BISON_FOUND)
if(CMAKE_SCRIPT_MODE_FILE)
set(verbose "")
else()
set(verbose VERBOSE) #REPORT_FILE json_parser.output)
set(verbose VERBOSE)
endif()

bison(
php_ext_json_parser
json_parser.y
${CMAKE_CURRENT_SOURCE_DIR}/json_parser.tab.c
${verbose}
HEADER
${verbose}
CODEGEN
)
endif()
Expand All @@ -41,7 +41,7 @@ if(RE2C_FOUND)
json_scanner.re
${CMAKE_CURRENT_SOURCE_DIR}/json_scanner.c
HEADER ${CMAKE_CURRENT_SOURCE_DIR}/php_json_scanner_defs.h
OPTIONS -bc
OPTIONS --bit-vectors --conditions
CODEGEN
)
endif()
2 changes: 1 addition & 1 deletion cmake/ext/phar/cmake/GenerateGrammar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(RE2C_FOUND)
php_ext_phar_path_check
phar_path_check.re
${CMAKE_CURRENT_SOURCE_DIR}/phar_path_check.c
OPTIONS -b
OPTIONS --bit-vectors
CODEGEN
)
endif()
4 changes: 2 additions & 2 deletions cmake/ext/standard/cmake/GenerateGrammar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ if(RE2C_FOUND)
php_ext_standard_url_scanner_ex
url_scanner_ex.re
${CMAKE_CURRENT_SOURCE_DIR}/url_scanner_ex.c
OPTIONS -b
OPTIONS --bit-vectors
CODEGEN
)

re2c(
php_ext_standard_var_unserializer
var_unserializer.re
${CMAKE_CURRENT_SOURCE_DIR}/var_unserializer.c
OPTIONS -b
OPTIONS --bit-vectors
CODEGEN
)
endif()
6 changes: 5 additions & 1 deletion cmake/sapi/phpdbg/cmake/GenerateGrammar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ if(RE2C_FOUND)
php_sapi_phpdbg_lexer
phpdbg_lexer.l
${CMAKE_CURRENT_SOURCE_DIR}/phpdbg_lexer.c
OPTIONS -cbdF
OPTIONS
--conditions
--debug-output
--bit-vectors
--flex-syntax
CODEGEN
)
endif()

0 comments on commit bfcbddd

Please sign in to comment.