MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / t_EXPR

Function t_EXPR

SLiCAP/SLiCAPlex.py:115–140  ·  view source on GitHub ↗

r'{[\w\(\)\/*+-\^ .]*}

(t)

Source from the content-addressed store, hash-verified

113 pass
114
115def 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
142def t_SCI(t):
143 r'[+-]?\d+\.?\d*[eE][+-]?\d+'

Callers

nothing calls this directly

Calls 2

_printErrorFunction · 0.85
groupMethod · 0.80

Tested by

no test coverage detected