tomlplusplus icon indicating copy to clipboard operation
tomlplusplus copied to clipboard

Event interface / SAX

Open mizvekov opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe. I'd like to consume the input file on the go, without having to create an intermediate DOM representation.

Describe the solution you'd like A SAX-like parser interface.

Additional context This would make it easier to use in some memory constrained situations.

mizvekov avatar May 31 '21 23:05 mizvekov

This would make it easier to use in some memory constrained situations.

Is this actually a blocker for you, or only hypothetical?

marzer avatar Jun 01 '21 05:06 marzer

Not so much of a blocker because:

  • Not even sure of JSON vs TOML as this point.
  • The language / grammar is simple enough that it would not be prohibitive to develop something in-house.

But however:

  • This is a potential replacement to something JSON based that already uses event-based interface.
  • Even other TOML C++ implementations offer event-based parser interface, but they however seem to be abandoned and otherwise not as of high quality as this one.

If supporting this feature would have undesired costs, I understand, but then please take this as a request to expound the reasoning behind it in the documentation :) And thanks for the effort in publishing this library, it's really well done and appreciated!

mizvekov avatar Jun 01 '21 20:06 mizvekov

Well truthfully my first reaction was "wow that would be so much work", but after thinking about it some more it probably wouldn't be all that hard after all. My implementation cheats somewhat by not doing the 'proper' lex+parse two-step, and instead only scans through the document once (needing only to keep a very small rewind buffer), so I could actually build an event-based interface fairly easily by simply invoking some user event instead of creating the nodes while walking the tree.

All that is moot, however, since I won't have time to do this for ages. The project's backlog is gradually getting away from me...

marzer avatar Jun 01 '21 21:06 marzer

No problem, totally understand :)

mizvekov avatar Jun 01 '21 21:06 mizvekov