Create an expression from a string. This is a "lazy" parser, that is, only arithmetic operations are resolved, non-arithmetic operations are treated as symbols.
(s, language=Language.C)
| 1270 | |
| 1271 | |
| 1272 | def fromstring(s, language=Language.C): |
| 1273 | """Create an expression from a string. |
| 1274 | |
| 1275 | This is a "lazy" parser, that is, only arithmetic operations are |
| 1276 | resolved, non-arithmetic operations are treated as symbols. |
| 1277 | """ |
| 1278 | r = _FromStringWorker(language=language).parse(s) |
| 1279 | if isinstance(r, Expr): |
| 1280 | return r |
| 1281 | raise ValueError(f'failed to parse `{s}` to Expr instance: got `{r}`') |
| 1282 | |
| 1283 | |
| 1284 | class _Pair: |
searching dependent graphs…