Skip to content

Commit

Permalink
Add basic support for Zig (no documentation).
Browse files Browse the repository at this point in the history
  • Loading branch information
skvadrik committed Jul 15, 2024
1 parent 74ace08 commit 5cd48a8
Show file tree
Hide file tree
Showing 58 changed files with 17,459 additions and 603 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option(RE2C_BUILD_RE2OCAML "Build re2ocaml executable (an alias for `re2c --lang
option(RE2C_BUILD_RE2PY "Build re2py executable (an alias for `re2c --lang python`)" ON)
option(RE2C_BUILD_RE2RUST "Build re2rust executable (an alias for `re2c --lang rust`)" ON)
option(RE2C_BUILD_RE2V "Build re2v executable (an alias for `re2c --lang v`)" ON)
option(RE2C_BUILD_RE2ZIG "Build re2zig executable (an alias for `re2c --lang zig`)" ON)

option(RE2C_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(RE2C_REGEN_BENCHMARKS "Regenerate C code for benchmarks" OFF)
Expand Down Expand Up @@ -142,6 +143,7 @@ add_library(re2c_objects_autogen OBJECT
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_python.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_rust.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_v.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_zig.cc"
"${re2c_docs}"
)
add_library(re2c_objects_autogen_ver_to_vernum OBJECT
Expand Down Expand Up @@ -230,6 +232,7 @@ re2c_bootstrap_syntax("include/syntax/ocaml" "src/default_syntax_ocaml.cc")
re2c_bootstrap_syntax("include/syntax/python" "src/default_syntax_python.cc")
re2c_bootstrap_syntax("include/syntax/rust" "src/default_syntax_rust.cc")
re2c_bootstrap_syntax("include/syntax/v" "src/default_syntax_v.cc")
re2c_bootstrap_syntax("include/syntax/zig" "src/default_syntax_zig.cc")

# re2c
add_executable(re2c ${re2c_sources})
Expand Down Expand Up @@ -315,6 +318,15 @@ if (RE2C_BUILD_RE2V)
)
endif()

# re2zig
if (RE2C_BUILD_RE2ZIG)
add_executable(re2zig ${re2c_sources})
target_compile_definitions(re2zig PUBLIC
"RE2C_LANG=Lang::ZIG"
"RE2C_PROG=\"re2zig\""
)
endif()

# docs
set(re2c_docs_sources
"${re2c_manpage_source}"
Expand Down Expand Up @@ -458,6 +470,9 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
if(RE2C_BUILD_RE2V)
install(TARGETS re2v RUNTIME DESTINATION bin)
endif()
if(RE2C_BUILD_RE2ZIG)
install(TARGETS re2zig RUNTIME DESTINATION bin)
endif()
install(FILES
include/syntax/c
include/syntax/d
Expand All @@ -469,6 +484,7 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
include/syntax/python
include/syntax/rust
include/syntax/v
include/syntax/zig
include/unicode_categories.re
DESTINATION "${RE2C_STDLIB_DIR}")

Expand Down
15 changes: 13 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ re2c_GEN_SRC = \
src/default_syntax_ocaml.cc \
src/default_syntax_python.cc \
src/default_syntax_rust.cc \
src/default_syntax_v.cc
src/default_syntax_v.cc \
src/default_syntax_zig.cc
re2c_GEN_HDR = \
src/options/parser.h \
src/options/conf_parser.h \
Expand Down Expand Up @@ -190,7 +191,8 @@ re2c_BOOT = \
bootstrap/src/default_syntax_ocaml.cc \
bootstrap/src/default_syntax_python.cc \
bootstrap/src/default_syntax_rust.cc \
bootstrap/src/default_syntax_v.cc
bootstrap/src/default_syntax_v.cc \
bootstrap/src/default_syntax_zig.cc

# custom sources
re2c_CUSTOM_HELP = doc/help.rst
Expand Down Expand Up @@ -339,6 +341,7 @@ dist_stdlib_DATA = \
include/syntax/python \
include/syntax/rust \
include/syntax/v \
include/syntax/zig \
include/unicode_categories.re

BAZELFILES := \
Expand Down Expand Up @@ -610,3 +613,11 @@ re2v_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::V -DRE2C_PROG=\"re2v\"
re2v_SOURCES = $(re2c_SOURCES)
nodist_re2v_SOURCES = $(nodist_re2c_SOURCES)
endif

# re2zig
if WITH_ZIG
bin_PROGRAMS += re2zig
re2zig_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::ZIG -DRE2C_PROG=\"re2zig\"
re2zig_SOURCES = $(re2c_SOURCES)
nodist_re2zig_SOURCES = $(nodist_re2c_SOURCES)
endif
Loading

0 comments on commit 5cd48a8

Please sign in to comment.