r'{[\w\(\)\/*+-\^ .]*}
(t)
| 113 | pass |
| 114 | |
| 115 | def t_EXPR(t): |
| 116 | r'{[\w\(\)\/*+-\^ .]*}' |
| 117 | """ |
| 118 | Replaces scale factors in expressions and converts the expression into |
| 119 | a sympy object. |
| 120 | """ |
| 121 | pos = 1 |
| 122 | out = '' |
| 123 | for m in re.finditer(r'\d+\.?\d*([yzafpnumkMGTP])', t.value): |
| 124 | out += t.value[pos: m.end()-1] + 'e' + _SCALEFACTORS[m.group(0)[-1]] |
| 125 | pos = m.end() |
| 126 | out += t.value[pos:-1] |
| 127 | t.value = out |
| 128 | try: |
| 129 | t.value = sp.sympify(out, rational=True) |
| 130 | except TypeError: |
| 131 | exc_type, value, exc_traceback = sys.exc_info() |
| 132 | print('\n', value) |
| 133 | _printError("Error in expression.", t) |
| 134 | lexer.errCount += 1 |
| 135 | except sp.SympifyError: |
| 136 | exc_type, value, exc_traceback = sys.exc_info() |
| 137 | print('\n', value) |
| 138 | _printError("Error in expression.", t) |
| 139 | lexer.errCount += 1 |
| 140 | return t |
| 141 | |
| 142 | def t_SCI(t): |
| 143 | r'[+-]?\d+\.?\d*[eE][+-]?\d+' |
nothing calls this directly
no test coverage detected