Skip to content

Commit

Permalink
Add usage example in Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoli committed Apr 14, 2016
1 parent 4778a54 commit b103d72
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
22 changes: 21 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,29 @@ Usage

.. code-block:: python
import asdl
from asdl import ASDLParser, parse
syntax = """
module Lambda {
term =
Lambda(name x, term body) |
Apply(term function, term argument) |
Variable(name x)
}
"""
print(ASDLParser().parse(syntax))
print(asdl.parse("./test/Python.asdl"))
Output:

.. code-block::
Module(Lambda, [Type(term, Sum([Constructor(Lambda, [Field(name, x), Field(term, body)]), Constructor(Apply, [Field(term, function), Field(term, argument)]), Constructor(Variable, [Field(name, x)])]))])
Module(Python, [Type(mod, Sum([Constructor(Module, [Field(stmt, body, seq=True)]), Constructor(Interactive, [Field(stmt, body, seq=True)]), Constructor(Expression, [Field(expr, body)]), Constructor(Suite, ...
License
-------
Expand Down
6 changes: 6 additions & 0 deletions test/Lambda.asdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Lambda {
term =
Lambda(name x, term body) |
Apply(term function, term argument) |
Variable(name x)
}
2 changes: 1 addition & 1 deletion test/test_asdl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the asdl parser in Parser/asdl.py"""
"""Tests for the asdl parser in asdl.py"""

import os
import unittest
Expand Down

0 comments on commit b103d72

Please sign in to comment.