(expr, vars, rules={})
| 3187 | |
| 3188 | |
| 3189 | def determineexprtype(expr, vars, rules={}): |
| 3190 | if expr in vars: |
| 3191 | return _ensure_exprdict(vars[expr]) |
| 3192 | expr = expr.strip() |
| 3193 | if determineexprtype_re_1.match(expr): |
| 3194 | return {'typespec': 'complex'} |
| 3195 | m = determineexprtype_re_2.match(expr) |
| 3196 | if m: |
| 3197 | if 'name' in m.groupdict() and m.group('name'): |
| 3198 | outmess( |
| 3199 | f'determineexprtype: selected kind types not supported ({repr(expr)})\n') |
| 3200 | return {'typespec': 'integer'} |
| 3201 | m = determineexprtype_re_3.match(expr) |
| 3202 | if m: |
| 3203 | if 'name' in m.groupdict() and m.group('name'): |
| 3204 | outmess( |
| 3205 | f'determineexprtype: selected kind types not supported ({repr(expr)})\n') |
| 3206 | return {'typespec': 'real'} |
| 3207 | for op in ['+', '-', '*', '/']: |
| 3208 | for e in [x.strip() for x in markoutercomma(expr, comma=op).split('@' + op + '@')]: |
| 3209 | if e in vars: |
| 3210 | return _ensure_exprdict(vars[e]) |
| 3211 | t = {} |
| 3212 | if determineexprtype_re_4.match(expr): # in parenthesis |
| 3213 | t = determineexprtype(expr[1:-1], vars, rules) |
| 3214 | else: |
| 3215 | m = determineexprtype_re_5.match(expr) |
| 3216 | if m: |
| 3217 | rn = m.group('name') |
| 3218 | t = determineexprtype(m.group('name'), vars, rules) |
| 3219 | if t and 'attrspec' in t: |
| 3220 | del t['attrspec'] |
| 3221 | if not t: |
| 3222 | if rn[0] in rules: |
| 3223 | return _ensure_exprdict(rules[rn[0]]) |
| 3224 | if expr[0] in '\'"': |
| 3225 | return {'typespec': 'character', 'charselector': {'*': '*'}} |
| 3226 | if not t: |
| 3227 | outmess( |
| 3228 | f'determineexprtype: could not determine expressions ({repr(expr)}) type.\n') |
| 3229 | return t |
| 3230 | |
| 3231 | ###### |
| 3232 |
no test coverage detected
searching dependent graphs…