Skip to content

Commit

Permalink
fixing 'jonasbugas'
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermenevesxyz committed Aug 20, 2022
1 parent fddd72b commit 01ad4fe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pobrelanglib/pl_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ def extract_expression(token: str) -> str:
return token.split(":", 1)[1]

def parse_math(expr: str, module: Module) -> str:
for var, val in module.variables.items():
expr = expr.replace(var, val)

sorted_vars = sorted(module.variables.keys(), key=len)

for var in reversed(sorted_vars):
expr = expr.replace(var, module.variables[var])

return str(float(eval(expr)))

def create_variable(type: str, name: str, value: str, module: Module) -> None:
Expand Down

0 comments on commit 01ad4fe

Please sign in to comment.