<commit_before>Python Recursive Descent Parser
===============================

A quick and dirty Recursive Descent Parser written using Python 3. The frontend abuses python's `data model <https://docs.python.org/3/reference/datamodel.html>`_ to make grammar definitions partially legible and easier to write. After a grammar is defined, it can be used to convert text into a parse tree.

Getting Started
===============

To begin defining your grammar, call the grammar function, and store the grammar context and grammar builder objects in separate variables.

.. code:: py

    from rdparser import grammar

    c, b = grammar()

The grammar context helps organize named rules and forward definitions. The grammar builder helps define syntax rules using built-in python data types and operations.

Next, construct rules using the builder and context objects.

.. code:: py

    # match an email address
    c.email = {r"[a-zA-Z0-9_.]+@[a-zA-Z0-9_.]+"}<commit_msg>Update README data model link<commit_after>Python Recursive Descent Parser
===============================

A quick and dirty Recursive Descent Parser written using Python 3. The frontend abuses python's `data model <https://docs.python.org/3/reference/datamodel.html#special-method-names>`_ to make grammar definitions partially legible and easier to write. After a grammar is defined, it can be used to convert text into a parse tree.

Getting Started
===============

To begin defining your grammar, call the grammar function, and store the grammar context and grammar builder objects in separate variables.

.. code:: py

    from rdparser import grammar

    c, b = grammar()

The grammar context helps organize named rules and forward definitions. The grammar builder helps define syntax rules using built-in python data types and operations.

Next, construct rules using the builder and context objects.

.. code:: py

    # match an email address
    c.email = {r"[a-zA-Z0-9_.]+@[a-zA-Z0-9_.]+"}
{'fraction_non_alphanumeric': 0.1122397155916709, 'fraction_numerical': 0.006094464195022855, 'mean_word_length': 4.309973045822103, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1936097', 'n_tokens_mistral': 542, 'n_tokens_neox': 489, 'n_words': 245}