Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

Commit

Permalink
Improve exponents
Browse files Browse the repository at this point in the history
Removed '**' for exponentiation and allowed x^b instead of x^{b}
  • Loading branch information
augustt198 committed Mar 19, 2016
1 parent f3d788f commit fe84db6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions PS.g4
Expand Up @@ -11,8 +11,6 @@ SUB: '-';
MUL: '*';
DIV: '/';

EXP: '**';

L_PAREN: '(';
R_PAREN: ')';
L_BRACE: '{';
Expand Down Expand Up @@ -115,8 +113,7 @@ eval_at_sup:
R_BRACE;

exp:
exp EXP exp
| exp CARET L_BRACE expr R_BRACE subexpr?
exp CARET (atom | L_BRACE expr R_BRACE) subexpr?
| comp;

comp:
Expand Down
6 changes: 3 additions & 3 deletions process_latex.py
Expand Up @@ -174,11 +174,11 @@ def convert_postfix(postfix):

def convert_exp(exp):
if exp.exp():
base = convert_exp(exp.exp(0))
base = convert_exp(exp.exp())
if isinstance(base, list):
raise Exception("Cannot raise derivative to power")
if exp.EXP():
exponent = convert_exp(exp.exp(1))
if exp.atom():
exponent = convert_atom(exp.atom())
elif exp.expr():
exponent = convert_expr(exp.expr())
return sympy.Pow(base, exponent, evaluate=False)
Expand Down

0 comments on commit fe84db6

Please sign in to comment.