Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Syntax highlight & test python examples #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ rules and provide new ones. Grammar rules are exposed as methods.
Example Usage
-------------

::

from parsley import makeGrammar
exampleGrammar = """
ones = '1' '1' -> 1
twos = '2' '2' -> 2
stuff = (ones | twos)+
"""
Example = makeGrammar(exampleGrammar, {})
g = Example("11221111")
result = g.stuff()
print result

→ ``[1, 2, 1, 1]``
.. code:: python

>>> from parsley import makeGrammar
>>> exampleGrammar = """
... ones = '1' '1' -> 1
... twos = '2' '2' -> 2
... stuff = (ones | twos)+
... """

>>> Example = makeGrammar(exampleGrammar, {})
>>> g = Example("11221111")
>>> g.stuff()
[1, 2, 1, 1]

4 changes: 3 additions & 1 deletion doc/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Extending Grammars and Inheritance
Another feature taken from OMeta is *grammar inheritance*. We can
write a grammar with rules that override ones in a parent. If we load
the grammar from our calculator tutorial as ``Calc``, we can extend it
with some constants::
with some constants:

.. code:: python

from parsley import makeGrammar
import math
Expand Down
4 changes: 2 additions & 2 deletions doc/terml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ trees.
Creating Terms
==============

::
.. code:: python

>>> from terml.nodes import termMaker as t
>>> t.Term()
term('Term')

That's it! We've created an empty term, `Term`, with nothing inside.

::
.. code:: python

>>> t.Num(1)
term('Num(1)')
Expand Down
Loading