I1: SML parser — inverse of to_sml()
Adds parse_sml(text) -> Item / try_parse_sml(text) -> optional<Item> in secs2/sml.hpp. Round-trips with the existing to_sml() emitter for every Item shape the codec produces: lists with nesting, ASCII / JIS8, Binary (decimal and 0xHH literals), Boolean (T/F or 1/0, scalar and multi-element), U1-U8 / I1-I8 / F4 / F8 vectors, and the optional `[n]` count syntax (accepted but not enforced). The parser is whitespace-insensitive outside quoted strings and uses a small Cursor type for read_word / read_quoted / skip_ws. Numeric literals go through strtoul/strtoll/strtod so SML can carry hex, octal, and decimal interchangeably (the emitter writes hex for Binary and decimal everywhere else). 11 test cases cover the full round-trip surface, the whitespace invariant, unknown-tag rejection, the try_parse error-swallowing variant, and the optional `[n]` count. secsgem-py has secs/sml.py for the same purpose; this brings the C++ port to parity on the tooling side. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,7 @@ add_custom_target(generate_messages DEPENDS ${MESSAGES_HPP})
|
||||
|
||||
add_library(secsgem
|
||||
src/secs2/codec.cpp
|
||||
src/secs2/sml.cpp
|
||||
src/hsms/header.cpp
|
||||
src/hsms/connection.cpp
|
||||
src/secsi/header.cpp
|
||||
@@ -110,6 +111,7 @@ add_executable(secsgem_tests
|
||||
tests/test_ept.cpp
|
||||
tests/test_cem_objects.cpp
|
||||
tests/test_modules.cpp
|
||||
tests/test_sml.cpp
|
||||
)
|
||||
target_link_libraries(secsgem_tests PRIVATE secsgem doctest::doctest)
|
||||
target_compile_definitions(secsgem_tests PRIVATE
|
||||
|
||||
Reference in New Issue
Block a user