Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New parser: event-based policy #414

Merged
merged 11 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,32 @@ jobs:

#----------------------------------------------------------------------------
coverage:
name: coverage/${{matrix.name}}
# if: github.ref == 'refs/heads/master'
name: coverage/c++${{matrix.std}}${{matrix.cmk}}
if: |
(!contains(github.event.head_commit.message, 'skip all')) ||
(!contains(github.event.head_commit.message, 'skip coverage')) ||
contains(github.event.head_commit.message, 'only coverage')
continue-on-error: true
if: always() # https://stackoverflow.com/questions/62045967/github-actions-is-there-a-way-to-continue-on-error-while-still-getting-correct
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
include:
- {name: c++11, std: 11, cxx: g++-9, cc: gcc-9, bt: Coverage, os: ubuntu-20.04}
- {name: c++17, std: 17, cxx: g++-9, cc: gcc-9, bt: Coverage, os: ubuntu-20.04}
#- {name: c++20, std: 20, cxx: g++-9, cc: gcc-9, bt: Coverage, os: ubuntu-20.04}
env: {
STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}",
CODECOV_TOKEN: "${{secrets.CODECOV_TOKEN}}",
COVERALLS_REPO_TOKEN: "${{secrets.COVERALLS_REPO_TOKEN}}",
COVERALLS_PARALLEL: true,
}
- {std: 11, cxx: g++-9, bt: Coverage, os: ubuntu-20.04}
- {std: 17, cxx: g++-9, bt: Coverage, os: ubuntu-20.04}
# test also with the debug code enabled
- {std: 11, cxx: g++-9, bt: Coverage, os: ubuntu-20.04, cmk: "-DRYML_DBG=ON"}
- {std: 17, cxx: g++-9, bt: Coverage, os: ubuntu-20.04, cmk: "-DRYML_DBG=ON"}
env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}",
BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}",
LINT: "${{matrix.lint}}", OS: "${{matrix.os}}",
CMAKE_FLAGS: "${{matrix.cmk}}",
CODECOV_TOKEN: "${{secrets.CODECOV_TOKEN}}",
COVERALLS_REPO_TOKEN: "${{secrets.COVERALLS_REPO_TOKEN}}",
# coveralls disabled: https://github.com/lemurheavy/coveralls-public/issues/1665
# https://docs.coveralls.io/parallel-build-webhook
#COVERALLS_PARALLEL: true
}
steps:
- {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}}
- {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}}
- name: setup emscripten cache
id: cache-system-libraries
uses: actions/cache@v3
uses: actions/cache@v4
with: {path: "${{env.EMSCRIPTEN_CACHE_FOLDER}}", key: "${{matrix.emver}}-${{runner.os}}"}
- name: setup emscripten
uses: mymindstorm/setup-emsdk@v11
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ jobs:
matrix:
config:
# name of the artifact | suffix (gen) | suffix (package) | cpack gen | mime type | os | cxx
- {name: Ubuntu 22.04 deb , sfxg: unix64.deb, sfxp: ubuntu-22.04.deb , gen: DEB , mime: vnd.debian.binary-package, os: ubuntu-22.04 }
- {name: Ubuntu 20.04 deb , sfxg: unix64.deb, sfxp: ubuntu-20.04.deb , gen: DEB , mime: vnd.debian.binary-package, os: ubuntu-20.04 }
#- {name: Ubuntu 18.04 deb , sfxg: unix64.deb, sfxp: ubuntu-18.04.deb , gen: DEB , mime: vnd.debian.binary-package, os: ubuntu-18.04 }
- {name: Windows VS2019 zip, sfxg: win64.zip , sfxp: windows-vs2019.zip , gen: ZIP , mime: zip , os: windows-2019, cxx: vs2019}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ build/
install/
.python-version
compile_commands.json
launch.json

# test files
/Testing/
Expand Down
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,30 @@ c4_add_library(ryml
c4/yml/common.cpp
c4/yml/emit.def.hpp
c4/yml/emit.hpp
c4/yml/event_handler_stack.hpp
c4/yml/event_handler_tree.hpp
c4/yml/filter_processor.hpp
c4/yml/fwd.hpp
c4/yml/export.hpp
c4/yml/node.hpp
c4/yml/node.cpp
c4/yml/node_type.hpp
c4/yml/node_type.cpp
c4/yml/parser_state.hpp
c4/yml/parse.hpp
c4/yml/parse.cpp
c4/yml/parse_engine.hpp
c4/yml/parse_engine.def.hpp
c4/yml/preprocess.hpp
c4/yml/preprocess.cpp
c4/yml/reference_resolver.hpp
c4/yml/reference_resolver.cpp
c4/yml/std/map.hpp
c4/yml/std/std.hpp
c4/yml/std/string.hpp
c4/yml/std/vector.hpp
c4/yml/tag.hpp
c4/yml/tag.cpp
c4/yml/tree.hpp
c4/yml/tree.cpp
c4/yml/writer.hpp
Expand Down Expand Up @@ -88,6 +101,13 @@ if(RYML_USE_ASSERT)
target_compile_definitions(ryml PUBLIC RYML_USE_ASSERT=1)
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
option(RYML_FANALYZER "Compile with -fanalyzer https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Static-Analyzer-Options.html" OFF)
if(RYML_FANALYZER)
target_compile_options(ryml PUBLIC -fanalyzer)
endif()
endif()


#-------------------------------------------------------

Expand Down
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,22 @@ See also [the roadmap](./ROADMAP.md) for a list of future work.
ryml deliberately makes no effort to follow the standard in the
following situations:

* Containers are not accepted as mapping keys: keys must be scalars.
* ryml's tree does NOT accept containers are as mapping keys: keys
must be scalars. HOWEVER, this is a limitation only of the tree. The
event-based parser engine DOES parse container keys. The parser
engine is the result of a recent refactor and its usage is meant to
be used by other programming languages to create their native
data-structures. This engine is fully tested and fully conformant
(other than the general error permissiveness noted below). But
because it is recent, it is still undocumented, and it requires some
API cleanup before being ready for isolated use. Please get in touch
if you are interested in integrating the event-based parser engine
without the standalone `ryml::parse_*()`
* Tab characters after `:` and `-` are not accepted tokens, unless
ryml is compiled with the macro `RYML_WITH_TAB_TOKENS`. This
requirement exists because checking for tabs introduces branching
into the parser's hot code and in some cases costs as much as 10%
in parsing time.
* Anchor names must not end with a terminating colon: eg `&anchor: key: val`.
* Non-unique map keys are allowed. Enforcing key uniqueness in the
parser or in the tree would cause log-linear parsing complexity (for
root children on a mostly flat tree), and would increase code size
Expand All @@ -754,18 +763,17 @@ following situations:
reflects the usual practice of having at most 1 or 2 tag directives;
also, be aware that this feature is under consideration for removal
in YAML 1.3.

Also, ryml tends to be on the permissive side where the YAML standard
dictates there should be an error; in many of these cases, ryml will
tolerate the input. This may be good or bad, but in any case is being
improved on (meaning ryml will grow progressively less tolerant of
YAML errors in the coming releases). So we strongly suggest to stay
away from those dark corners of YAML which are generally a source of
problems, which is a good practice anyway.
* ryml tends to be on the permissive side in several cases where the
YAML standard dictates that there should be an error; in many of these
cases, ryml will tolerate the input. This may be good or bad, but in
any case is being improved on, meaning ryml will grow progressively
less tolerant of YAML errors in the coming releases. So we strongly
suggest to stay away from those dark corners of YAML which are
generally a source of problems; this is good practice anyway.

If you do run into trouble and would like to investigate conformance
of your YAML code, beware of existing online YAML linters, many of
which are not fully conformant; instead, try using
of your YAML code, **beware** of existing online YAML linters, many of
which are not fully conformant. Instead, try using
[https://play.yaml.io](https://play.yaml.io), an amazing tool which
lets you dynamically input your YAML and continuously see the results
from all the existing parsers (kudos to @ingydotnet and the people
Expand Down
10 changes: 10 additions & 0 deletions api/python/tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,22 @@ def check(self, ut, t, is_json=False):
eq(t.val(8), b"2")
eq(t.val(9), b"3")
if not is_json:
tr(t.is_key_squo(1))
fs(t.is_key_squo(2))
fs(t.is_key_squo(3))
fs(t.is_key_squo(4))
fs(t.is_key_squo(5))
tr(t.is_key_quoted(1))
fs(t.is_key_quoted(2))
fs(t.is_key_quoted(3))
fs(t.is_key_quoted(4))
fs(t.is_key_quoted(5))
else:
tr(t.is_key_dquo(1))
tr(t.is_key_dquo(2))
tr(t.is_key_dquo(3))
tr(t.is_key_dquo(4))
tr(t.is_key_dquo(5))
tr(t.is_key_quoted(1))
tr(t.is_key_quoted(2))
tr(t.is_key_quoted(3))
Expand Down
Loading
Loading