TatSu icon indicating copy to clipboard operation
TatSu copied to clipboard

Need more examples.

Open gachiemchiep opened this issue 7 years ago • 5 comments

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

gachiemchiep avatar Jun 05 '17 05:06 gachiemchiep

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.

apalala avatar Jun 07 '17 22:06 apalala

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.

dnicolodi avatar Jun 04 '22 18:06 dnicolodi

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.

apalala avatar Jul 11 '22 12:07 apalala

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.

dnicolodi avatar Jul 12 '22 18:07 dnicolodi

By the way, my first use of TatSu ended up looking like this https://github.com/beancount/beanquery/pull/99

dnicolodi avatar Jul 12 '22 18:07 dnicolodi

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.

jokoon avatar Jan 18 '23 14:01 jokoon

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.

apalala avatar Aug 24 '23 19:08 apalala