#pragma once #include #include #include #include "secsgem/secs2/item.hpp" // SML (SECS Message Language) parser — the inverse of `to_sml()` in // codec.cpp. Accepts the same human-readable form emitted by // Item::sml() / Message::sml(): each item is `` // with nesting for lists. Strings are quoted; numeric literals are // whitespace-separated; binary bytes use `0x` prefix or decimal. // // The grammar is loose but unambiguous. Whitespace (incl. newlines) // is insignificant outside of quoted strings. The optional `[n]` // count is accepted but not enforced — actual element counts come // from the values that follow. Boolean accepts T/F as well as 1/0. namespace secsgem::secs2 { class SmlError : public std::runtime_error { public: using std::runtime_error::runtime_error; }; // Parse a single Item. Throws SmlError on a malformed input. Item parse_sml(const std::string& text); // Try-style variant that returns nullopt instead of throwing. std::optional try_parse_sml(const std::string& text); } // namespace secsgem::secs2