File: examples.rst

package info (click to toggle)
python-tatsu 5.17.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,516 kB
  • sloc: python: 13,185; makefile: 127
file content (39 lines) | stat: -rw-r--r-- 1,233 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.. Copyright (c) 2017-2026 Juancarlo AƱez (apalala@gmail.com)
.. SPDX-License-Identifier: BSD-4-Clause

.. include:: links.rst


Examples
--------

TatSu
~~~~~

The file ``grammar/tatsu.tatsu`` contains a grammar for the |TatSu| grammar
language written in the same language. The grammar is used in the
*bootstrap* test suite to prove that |TatSu| can generate a parser to
parse its own language. The parser output from the tests si made the main parser every time |TatSu| is stable (see ``tatsu/bootstrap.py`` for
the generated parser).

|TatSu| uses |TatSu| to translate grammars into parsers, so it is a
good example of end-to-end translation.


Calc
~~~~

The project ``examples/calc`` implements a calculator for simple
expressions, and is written as a tutorial over most of the features
provided by |TatSu|.


g2e
~~~

The project ``examples/g2e`` contains an example `ANTLR`_ to |TatSu| grammar
translation. The project uses ``g2e`` to generate a |TatSu| grammar
from the ``Python3.g4`` ANTLR_ grammar. Because the model classes used are
|TatSu|'s own (``grammars.*``), the same strategy can be used to
generate a parser from any other `ANTLR`_ grammar. Please take a look at the
examples *README* to know about limitations.