projects
/
linpy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Access to ISL version, just in case
[linpy.git]
/
pypol
/
linexprs.py
diff --git
a/pypol/linexprs.py
b/pypol/linexprs.py
index
0db7edd
..
9ab5c86
100644
(file)
--- a/
pypol/linexprs.py
+++ b/
pypol/linexprs.py
@@
-252,9
+252,12
@@
class Expression:
return left / right
raise SyntaxError('invalid syntax')
return left / right
raise SyntaxError('invalid syntax')
+ _RE_NUM_VAR = re.compile(r'(\d+|\))\s*([^\W\d_]\w*|\()')
+
@classmethod
def fromstring(cls, string):
@classmethod
def fromstring(cls, string):
- string = re.sub(r'(\d+|\))\s*([^\W\d_]\w*|\()', r'\1*\2', string)
+ # add implicit multiplication operators, e.g. '5x' -> '5*x'
+ string = cls._RE_NUM_VAR.sub(r'\1*\2', string)
tree = ast.parse(string, 'eval')
return cls._fromast(tree)
tree = ast.parse(string, 'eval')
return cls._fromast(tree)