libfsm icon indicating copy to clipboard operation
libfsm copied to clipboard

Simple `lx -l json` printer

Open jameysharp opened this issue 5 years ago • 3 comments

I don't know what I'm doing but with enough copy-paste from other parts of the source tree I made a thing!

jameysharp avatar Feb 24 '19 03:02 jameysharp

Thanks for reviewing! Your feedback makes sense. I'm working on something else right now so I'm not sure when I'd get back to this, but I probably will eventually... :sweat_smile: For the moment, though:

I didn't realize this, but I guess libfsm and re can already output JSON—and apparently in two styles, with or without IR optimizations, at that? You have a comment in libfsm/print/irjson.c saying "TODO: leaf callback for json output", which I assume is the main thing that's missing for lx to be able to use it as well. Is there more to it than that?

jameysharp avatar Mar 17 '19 19:03 jameysharp

So they do! Replace it with a better schema if you prefer.

The leaf callback is how lx renders things attached by its void *opaque - you can see that used for he generated C (to undertake zone changes) and for re's dot output (to print regexp indicies). It's a bit of an ugly arrangement, but it allows libfsm to print the graph, and callers to be responsible for rendering their own private concepts. I do think you'd want the same for json.

No worries about time! We're all busy with things. These APIs won't change, and I think this PR can wait as long as it needs.

katef avatar Mar 18 '19 00:03 katef

See #198 for new json for libfsm - this doesn't include the lx parts.

katef avatar Jan 17 '20 07:01 katef