Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
NielXu committed Jun 11, 2019
1 parent 0733068 commit 1802e4a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
@@ -1,17 +1,17 @@
# Intro
# pexpr
`pexpr` is a module that contains tools to convert from expressions to Abstract Syntax Tree. After that, it can be evaluated(if possible), transformed(prefix, infix, postfix) or even converted to Latex code to generate the expression PDF.

# CLI
To quickly calculate a math expression just type in command line:
```
```python
python ast.py "(1*2+max(4,5)/3)"
```
and the result will be:
```
3.666666666666667
```
To view the tree, enable the view feature by:
```
```python
python ast.py -v "(1*2+max(4,5)/3)"
```
The result will be the following:
Expand All @@ -26,6 +26,13 @@ The result will be the following:
/ \
(4) (5)
```
To generate a PDF from the given expression, enable preview feature:
```python
python ast.py -p "(1*2+max(4,5)/3)"
```

<b>Note:</b> To use features related to PDF, please download [miktex](https://miktex.org/download)

<b>Note:</b> quotation is required since there are special characters in some cases

<b>Note:</b> brackets are required since minus sign is a special character
Expand Down Expand Up @@ -92,6 +99,8 @@ the output will be displayed on the console:
```

# Latex
<b>Note:</b> To use features related to PDF, please download [miktex](https://miktex.org/download)

`lat.py` module allows you to convert from python math expressions to latex codes. For instance:
```python
tree = build("2+pi*sin(x+2)/cos(x^(y+1))") # Build a ast first
Expand All @@ -104,7 +113,6 @@ Furthermore, you can generate .tex file by given latex code. The file will only
gentex(lat_expr, "/location", "name") # Save .tex file to location with name
```
After that, a pdf file can be generated by compiling the .tex file
<b>(Please make sure you have pdflatex installed)</b>
```python
genpdf("/location/name.tex", "/target") # Compiling .tex file from source and save the files to target location
```
Expand Down

0 comments on commit 1802e4a

Please sign in to comment.