Esempio n. 1
0
    def test_extractnames(self):
        ss = "-+12354.5678E-12_aoeu"
        expr = parse(ss)

        xtor = ExtractNames()
        xtor.visit(expr)
        eq_(xtor.names, ['aoeu'])

        ss2 = ".02808_a123_45"
        expr = parse(ss2)

        xtor = ExtractNames()
        xtor.visit(expr)
        eq_(xtor.names, ['a123_45'])

        funccall = parse("foo(a, b-3+x(14), c=d+1)")
        xtor = ExtractNames()
        xtor.visit(funccall)
        eq_(xtor.names, ['a', 'b', 'd'])
        eq_(xtor.funcnames, ['foo', 'x'])

        power = parse("+1**2_a8")
        xtor = ExtractNames()
        xtor.visit(power)
        eq_(xtor.names, ['a8'])
        eq_(xtor.funcnames, [])
Esempio n. 2
0
 def test_char_lit_const(self):
     clc2 = parse("aoeu_'1202\"04''028'").subexpr[0]
     clc3 = parse('1_"as ""onthu\'sanetu"').subexpr[0]
     eq_(clc2.kind.param.name, 'aoeu')
     eq_(clc2.string, '1202"04\'028')
     eq_(clc3.kind.param.digit_string, '1')
     eq_(clc3.string, 'as "onthu\'sanetu')
Esempio n. 3
0
 def test_char_lit_const(self):
     clc2 = parse("aoeu_'1202\"04''028'").subexpr[0]
     clc3 = parse('1_"as ""onthu\'sanetu"').subexpr[0]
     eq_(clc2.kind.param.name, 'aoeu')
     eq_(clc2.string, '1202"04\'028')
     eq_(clc3.kind.param.digit_string, '1')
     eq_(clc3.string, 'as "onthu\'sanetu')
Esempio n. 4
0
    def test_extractnames(self):
        ss = "-+12354.5678E-12_aoeu"
        expr = parse(ss)

        xtor = ExtractNames()
        xtor.visit(expr)
        eq_(xtor.names, ['aoeu'])

        ss2 = ".02808_a123_45"
        expr = parse(ss2)

        xtor = ExtractNames()
        xtor.visit(expr)
        eq_(xtor.names, ['a123_45'])

        funccall = parse("foo(a, b-3+x(14), c=d+1)")
        xtor = ExtractNames()
        xtor.visit(funccall)
        eq_(xtor.names, ['a', 'b', 'd'])
        eq_(xtor.funcnames, ['foo', 'x'])

        power = parse("+1**2_a8")
        xtor = ExtractNames()
        xtor.visit(power)
        eq_(xtor.names, ['a8'])
        eq_(xtor.funcnames, [])
Esempio n. 5
0
 def __init__(self, expr_str):
     self.expr_str = expr_str.lower()
     self._expr = fort_expr.parse(self.expr_str)
     xtor = fort_expr.ExtractNames()
     xtor.visit(self._expr)
     self.funcnames = set(xtor.funcnames)
     self.names = set(xtor.names).union(self.funcnames)
Esempio n. 6
0
 def __init__(self, expr_str):
     self.expr_str = expr_str.lower()
     self._expr = fort_expr.parse(self.expr_str)
     xtor = fort_expr.ExtractNames()
     xtor.visit(self._expr)
     self.funcnames = set(xtor.funcnames)
     self.names = set(xtor.names).union(self.funcnames)
Esempio n. 7
0
def _tester(tstr, res, funcs=None):
    expr = parse(tstr)
    xtor = ExtractNames()
    xtor.visit(expr)
    eq_(xtor.names, res)
    if funcs:
        eq_(xtor.funcnames, funcs)
Esempio n. 8
0
def _tester(tstr, res, funcs=None):
    expr = parse(tstr)
    xtor = ExtractNames()
    xtor.visit(expr)
    eq_(xtor.names, res)
    if funcs:
        eq_(xtor.funcnames, funcs)
Esempio n. 9
0
 def test_func_ref(self):
     ss = "foo(a, b-3+x(14), c=d+1)"
     expr = parse(ss)
Esempio n. 10
0
 def test_func_ref(self):
     ss = "foo(a, b-3+x(14), c=d+1)"
     expr = parse(ss)