:orphan:

Examples for Lark
=================

**How to run the examples**:

After cloning the repo, open the terminal into the root directory of the
project, and run the following:

.. code:: bash

   [lark]$ python -m examples.<name_of_example>

For example, the following will parse all the Python files in the
standard library of your local installation:

.. code:: bash

   [lark]$ python -m examples.python_parser

Beginner Examples
~~~~~~~~~~~~~~~~~



.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A demonstration of parsing indentation (“whitespace significant” language) and the usage of the...">

.. only:: html

    .. figure:: /examples/images/thumb/sphx_glr_indented_tree_thumb.png

        :ref:`sphx_glr_examples_indented_tree.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/indented_tree

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A reference implementation of the Lark grammar (using LALR(1)) ">

.. only:: html

    .. figure:: /examples/images/thumb/sphx_glr_lark_grammar_thumb.png

        :ref:`sphx_glr_examples_lark_grammar.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/lark_grammar

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A demonstration of ambiguity">

.. only:: html

    .. figure:: /examples/images/thumb/sphx_glr_fruitflies_thumb.png

        :ref:`sphx_glr_examples_fruitflies.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/fruitflies

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A simple example of a REPL calculator">

.. only:: html

    .. figure:: /examples/images/thumb/sphx_glr_calc_thumb.png

        :ref:`sphx_glr_examples_calc.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/calc

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Implements a LOGO-like toy language for Python’s turtle, with interpreter. ">

.. only:: html

    .. figure:: /examples/images/thumb/sphx_glr_turtle_dsl_thumb.png

        :ref:`sphx_glr_examples_turtle_dsl.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/turtle_dsl

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The code is short and clear, and outperforms every other parser (that&#x27;s written in Python). For...">

.. only:: html

    .. figure:: /examples/images/thumb/sphx_glr_json_parser_thumb.png

        :ref:`sphx_glr_examples_json_parser.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/json_parser
.. raw:: html

    <div style='clear:both'></div>



.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-gallery


  .. container:: sphx-glr-download

    :download:`Download all examples in Python source code: examples_python.zip <//build/python-lark-0.10.0/docs/examples/examples_python.zip>`



  .. container:: sphx-glr-download

    :download:`Download all examples in Jupyter notebooks: examples_jupyter.zip <//build/python-lark-0.10.0/docs/examples/examples_jupyter.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
