3 ms·
I don’t think any of the approaches in this article are appropriate for the stated problem. Specifically, parsing data from an INI/JSON/text file (or TLV-like e
by vrtx0 6y ago
I don’t think any of the approaches in this article are appropriate for the stated problem. Specifically, parsing data from an INI/JSON/text file (or TLV-like encoding, predefined format/protocol, etc.), the parser can produce appropriate structures for the underlying data. This is the phase when you analyze (and likely validate) the input data, so you’d know the appropriate type after parsing.
You may want your parse tree to produce objects instead of fundamental C++ types (e.g. with functions like isNull(), isValid(), etc.). A common approach might be to produce a simple AST where each node includes just the fundamental type you’re interested in. Then you can simply follow the visitor pattern and write visitors for things like serializing/deserializing, generating/traversing/executing trees/graphs/code, etc...
Perhaps I’m missing something though? A more concrete definition of the problem would be helpful...