Skip to content
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ Dev Environment Setup
=====================
- Prerequisite:
- python 3.6+
- R
- It is preferable to have a dedicated virtualenv for this project:
```
$ git clone <this repo>
$ cd Tyrell
$ cd Trinity
$ mkdir venv
$ python3 -m venv venv
$ source venv/bin/activate
```
- Make an editable install with `pip`. This would automatically handles package dependencies. One of our dependency, `z3-solver`, takes a long time to build. Please be patient.
```
$ pip install wheel
$ pip install -e ".[dev]"
$ python setup.py sdist # for package
```
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/01_language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ The :func:`~tyrell.spec.do_parse.parse_file` function takes file path as a param
.. code-block:: python

from tyrell.spec import parse
spec = parse_file(r'''
spec = parse(r'''
enum IntConst {
"0", "1", "2"
}
Expand Down Expand Up @@ -176,9 +176,9 @@ For example, a simple interpreter for the small language we defined in the previ

# Create the interpreter object and run it
interp = BinaryArithFuncInterpreter()
print(interp.eval(builder.from_sexp_string('(@param 0)', [3, 4]))) # Prints 0
print(interp.eval(builder.from_sexp_string('(const (IntConst 1))', [3, 4]))) # Prints 0
print(interp.eval(builder.from_sexp_string('(plus (@param 1) (IntConst 2))', [3, 4]))) # Prints 0
print(interp.eval(builder.from_sexp_string('(@param 0)'), [3, 4])) # Prints 0
print(interp.eval(builder.from_sexp_string('(const (IntConst 1))'), [3, 4])) # Prints 0
print(interp.eval(builder.from_sexp_string('(plus (@param 1) (const (IntConst 2)))'), [3, 4])) # Prints 0

Well, this is not a super interesting interpreter, as it interprets any program to ``0``. To make it more interesting, we could have examined what the structure of ``node`` is, and take different actions according to whether it's a parameter, an enum, or a function application (in which case you may need to recurse down and interpret its arguments).

Expand Down