-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rapidyaml: Add parsing of ys to integer-based events
Adds a parser producing integer events, and integers signifying strings by indexing into the parsed YS string. Each event is provided as an integer bitmask. The event bits are defined in both the C++ side (ysparse_evt_handler.hpp) and the Java side (org.rapidyaml.Evt), and they need to stay consistent on both ends. When a string is associated with an event, it is provided as an integer offset and length. For example, the YAML `say: 2 + 2` produces the following sequence of integers: ```c++ BSTR, BDOC, VAL|BMAP|BLCK, KEY|SCLR|PLAI, 0, 3, // "say" VAL|SCLR|PLAI, 5, 5, // "2 + 2" EMAP, EDOC, ESTR, ``` Note that the scalar events, ie "say" and "2 + 2", are followed each by two extra integers encoding the offset and length of the scalar's string. These two extra integers are present whenever the event has any of the bits SCLR, ALIA, ANCH or TAG. For ease of use, there is a bitmask HAS_STR, which enables quick testing by a simple `flags & HAS_STR`. Also, where a string requires filtering, the parser filters it in-place in the input string, and returns the extra integers pertaining to the resulting filtered string. The existing EDN-producing parser was not removed, and the EVT-producing parser was added both on C++ and on the Java JNI bridge. Tests were enlarged to cover the new event parsing, both for C++ and Java. To benefit from this approach, the YS side must implement a mechanism to convert the int event sequence into its internal data-structure, using the symbols in the class org.rapidyaml.Evt. Other changes: - rapidyaml->ysparse: start renaming the C++ library providing the JNI. ysparse is a more accurate description of what the library does. - Directly use only the required rapidyaml source files instead of amalgamating into a single header. - Makefile: - Add target to generate the JNI header - Improve target dependencies
- Loading branch information
Showing
20 changed files
with
2,081 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/rapidyaml/ | ||
/rapidyaml-build/ | ||
/rapidyaml_all.hpp | ||
/_build/ | ||
/librapidyaml.* | ||
/.cache | ||
/compile_commands.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,69 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
project(rapidyaml | ||
DESCRIPTION "rapidyaml -> yamlscript" | ||
project(ysparse | ||
DESCRIPTION "ysparse: rapidyaml -> yamlscript" | ||
HOMEPAGE_URL "https://github.com/biojppm/rapidyaml -> https://github.com/yaml/yamlscript" | ||
LANGUAGES CXX) | ||
|
||
find_package(JNI REQUIRED) | ||
|
||
option(YS2EDN_TIMED "add timings to sections" OFF) | ||
option(YSPARSE_TIMED "add timings to sections" OFF) | ||
option(YSPARSE_DBG "enable debug logs" OFF) | ||
|
||
if(UNIX) | ||
set(CMAKE_SHARED_LIBRARY_SUFFIX .so) | ||
endif() | ||
|
||
add_library(rapidyaml | ||
set(libname rapidyaml) # TODO rename to ysparse | ||
|
||
add_library(${libname} | ||
# | ||
# JNI bridge | ||
org_rapidyaml_Rapidyaml.h | ||
org_rapidyaml_Rapidyaml.cpp | ||
rapidyaml_all.hpp | ||
rapidyaml_edn_handler.hpp | ||
rapidyaml_edn_handler.cpp | ||
rapidyaml_edn.hpp | ||
rapidyaml_edn.cpp | ||
# | ||
# ysparse files | ||
ysparse_edn_handler.hpp | ||
ysparse_edn_handler.cpp | ||
ysparse_edn.hpp | ||
ysparse_edn.cpp | ||
ysparse_evt_handler.hpp | ||
ysparse_evt_handler.cpp | ||
ysparse_evt.hpp | ||
ysparse_evt.cpp | ||
# | ||
# files required from rapidyaml | ||
rapidyaml/src/c4/yml/common.cpp | ||
rapidyaml/src/c4/yml/node_type.cpp | ||
rapidyaml/src/c4/yml/parse.cpp | ||
rapidyaml/src/c4/yml/tree.cpp | ||
rapidyaml/src/c4/yml/tag.cpp | ||
rapidyaml/src/c4/yml/reference_resolver.cpp | ||
# | ||
# files required from rapidyaml/ext/c4core | ||
rapidyaml/ext/c4core/src/c4/base64.cpp | ||
rapidyaml/ext/c4core/src/c4/error.cpp | ||
rapidyaml/ext/c4core/src/c4/language.cpp | ||
rapidyaml/ext/c4core/src/c4/utf.cpp | ||
) | ||
target_include_directories(rapidyaml PUBLIC | ||
target_include_directories(${libname} PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR} | ||
${CMAKE_CURRENT_LIST_DIR}/rapidyaml/test | ||
${CMAKE_CURRENT_LIST_DIR}/rapidyaml/src | ||
${CMAKE_CURRENT_LIST_DIR}/rapidyaml/ext/c4core/src | ||
) | ||
target_compile_definitions(rapidyaml PUBLIC | ||
target_compile_definitions(${libname} PUBLIC | ||
RYML_WITH_TAB_TOKENS | ||
RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS | ||
RYML_SINGLE_HEADER | ||
$<$<BOOL:${YS2EDN_TIMED}>:YS2EDN_TIMED> | ||
$<$<BOOL:${YSPARSE_TIMED}>:YSPARSE_TIMED> | ||
$<$<BOOL:${YSPARSE_DBG}>:RYML_DBG> | ||
) | ||
set_target_properties(rapidyaml PROPERTIES CXX_STANDARD 17) | ||
set_target_properties(${libname} PROPERTIES CXX_STANDARD 17) | ||
|
||
# target_link_libraries(rapidyaml PUBLIC JNI::JNI) | ||
target_include_directories(rapidyaml PUBLIC ${JNI_INCLUDE_DIRS}) | ||
target_include_directories(${libname} PUBLIC ${JNI_INCLUDE_DIRS}) | ||
|
||
add_executable(rapidyaml-test rapidyaml_test.cpp) | ||
target_link_libraries(rapidyaml-test rapidyaml) | ||
add_custom_target(rapidyaml-test-run | ||
DEPENDS rapidyaml-test | ||
COMMAND $<TARGET_FILE:rapidyaml-test> | ||
add_executable(${libname}-test ysparse_test.cpp) | ||
target_link_libraries(${libname}-test ${libname}) | ||
add_custom_target(${libname}-test-run | ||
DEPENDS ${libname}-test | ||
COMMAND $<TARGET_FILE:${libname}-test> | ||
COMMENT "running C++ tests" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.