Closed gachiemchiep closed 1 year ago
More examples would be good, and they will come.
Many of the examples for PyParsing have been contributed by users, but it's only since the move to TatSu (from Grako) that the tool has started having a less "hard core" and a more friendly face to beginners.
We'll get there.
I think the documentation is already in a very good shape even without that many examples as most of the knowledge about writing a PEG parser applies to TatSu with minimal changes. On the other hand, I would find very useful an example of how to integrate a generated parser with a generated object model into a project. It is not rocket science, but in doing it I hit a few rough edges that make me wonder whether I am doing it right.
With the latest TatSu you only need a NodeWalker
subclass to traverse the generated model. In my projects I write different walkers for different purposes: translation to another model, metrics, code generation.
On your line of thinking it may be necessary to make ParserConfing.semantics
default to ModelBuilderSemantics
to provide a minimal route of least effort and surprise. The problem is this approach would not work for dynamic parsing unless the object model module was generated.
Maybe most users of TatSu get away by traversing the generated the JSON-like output.
What it is not clear to me is the purpose of the object model code generator. Is the generated code supposed to be edited? Importing the generated code does not seem to be faster than using the dynamically generated one.
I have the impression that TatSu can be used in different ways: object model vs simple AST, generated code vs dynamic parser, ... I think it would be useful to have an example parser put together in the different ways with a minimal discussion of the tradeoffs. It would help to get started on TatSu and to better understand which usage model better fits an use case.
I don't think changes to TatSu are necessary.
By the way, my first use of TatSu ended up looking like this https://github.com/beancount/beanquery/pull/99
I'm currently trying to parse a C subset (no typedef so no most vexing parse, no function pointer), and I don't understand why I can't manage to parse function calls.
I hac a problem with the rule ordering when using or in the grammar, I fixed it, but now I'm quite stuck and I really have no idea how to move forward.
I would be nice to have some sort of pseudo C parser example.
I will try to post a grammar example.
Simply stated, there's no funding to create more grammar examples. I know of many who are using TatSu successfully, and the might want to contribute their work.
As the title said. Tatsu need more examples which are easier to understand and following Current examples are too big and hard to understand.
Pyparsing has a lot of examples which i found easier for beginner. http://pyparsing.wikispaces.com/Examples