MCPcopy Create free account
hub / github.com/numpy/numpy / determineexprtype

Function determineexprtype

numpy/f2py/crackfortran.py:3225–3265  ·  view source on GitHub ↗
(expr, vars, rules={})

Source from the content-addressed store, hash-verified

3223
3224
3225def determineexprtype(expr, vars, rules={}):
3226 if expr in vars:
3227 return _ensure_exprdict(vars[expr])
3228 expr = expr.strip()
3229 if determineexprtype_re_1.match(expr):
3230 return {'typespec': 'complex'}
3231 m = determineexprtype_re_2.match(expr)
3232 if m:
3233 if 'name' in m.groupdict() and m.group('name'):
3234 outmess(
3235 'determineexprtype: selected kind types not supported (%s)\n' % repr(expr))
3236 return {'typespec': 'integer'}
3237 m = determineexprtype_re_3.match(expr)
3238 if m:
3239 if 'name' in m.groupdict() and m.group('name'):
3240 outmess(
3241 'determineexprtype: selected kind types not supported (%s)\n' % repr(expr))
3242 return {'typespec': 'real'}
3243 for op in ['+', '-', '*', '/']:
3244 for e in [x.strip() for x in markoutercomma(expr, comma=op).split('@' + op + '@')]:
3245 if e in vars:
3246 return _ensure_exprdict(vars[e])
3247 t = {}
3248 if determineexprtype_re_4.match(expr): # in parenthesis
3249 t = determineexprtype(expr[1:-1], vars, rules)
3250 else:
3251 m = determineexprtype_re_5.match(expr)
3252 if m:
3253 rn = m.group('name')
3254 t = determineexprtype(m.group('name'), vars, rules)
3255 if t and 'attrspec' in t:
3256 del t['attrspec']
3257 if not t:
3258 if rn[0] in rules:
3259 return _ensure_exprdict(rules[rn[0]])
3260 if expr[0] in '\'"':
3261 return {'typespec': 'character', 'charselector': {'*': '*'}}
3262 if not t:
3263 outmess(
3264 'determineexprtype: could not determine expressions (%s) type.\n' % (repr(expr)))
3265 return t
3266
3267######
3268

Callers 2

analyzelineFunction · 0.85
expr2nameFunction · 0.85

Calls 5

_ensure_exprdictFunction · 0.85
markoutercommaFunction · 0.85
stripMethod · 0.80
outmessFunction · 0.70
splitMethod · 0.45

Tested by

no test coverage detected