Exemplo n.º 1
0
 def setUp(self):
     self.clearOutput()
     self.s = gl_.SYMBOL_TABLE = SymbolTable()
     l1, l2, l3, l4 = 1, 2, 3, 4
     b = symbols.BOUND(l1, l2)
     c = symbols.BOUND(l3, l4)
     self.bounds = symbols.BOUNDLIST.make_node(None, b, c)
     self.func = symbols.FUNCDECL.make_node('testfunction', 1)
Exemplo n.º 2
0
 def test_is_undeclared(self):
     s = SymbolTable()
     # Checks variable 'a' is undeclared
     self.assertTrue(s.check_is_undeclared('a', 10, show_error=False))
     s.declare_variable('a', 10, self.btyperef(TYPE.integer))
     # Checks variable 'a' is not undeclared
     self.assertFalse(s.check_is_undeclared('a', 10, show_error=False))
Exemplo n.º 3
0
 def test_get_entry(self):
     s = SymbolTable()
     var_a = s.get_entry('a')
     self.assertIsNone(var_a)
     s.declare_variable('a', 10, self.btyperef(TYPE.integer))
     var_a = s.get_entry('a')
     self.assertIsNotNone(var_a)
     self.assertIsInstance(var_a, symbols.VAR)
     self.assertEqual(var_a.scope, SCOPE.global_)
Exemplo n.º 4
0
    def setUp(self):
        zxbpp.init()
        l1 = 1
        l2 = 2
        l3 = 3
        l4 = 4
        b = symbols.BOUND(l1, l2)
        c = symbols.BOUND(l3, l4)
        self.bounds = symbols.BOUNDLIST.make_node(None, b, c)
        self.arr = symbols.VARARRAY('test', self.bounds, 1, type_=Type.ubyte)
        self.arg = symbols.ARGLIST(
            symbols.ARGUMENT(symbols.NUMBER(2, 1, type_=Type.uinteger), 1),
            symbols.ARGUMENT(symbols.NUMBER(3, 1, type_=Type.uinteger), 1))
        gl.SYMBOL_TABLE = SymbolTable()
        # Clears stderr and prepares for capturing it
        del config.OPTIONS.stderr
        config.OPTIONS.add_option('stderr', None, StringIO())
        config.OPTIONS.add_option_if_not_defined('explicit', None, False)

        self.aa1 = symbols.ARRAYACCESS(self.arr, self.arg, 2, 'fake-filename')
Exemplo n.º 5
0
    def setUp(self):
        zxbpp.init()
        l1 = 1
        l2 = 2
        l3 = 3
        l4 = 4
        b = symbols.BOUND(l1, l2)
        c = symbols.BOUND(l3, l4)
        self.bounds = symbols.BOUNDLIST.make_node(None, b, c)
        self.arr = symbols.VARARRAY('test', self.bounds, 1, type_=Type.ubyte)
        self.arg = symbols.ARGLIST(
            symbols.ARGUMENT(symbols.NUMBER(2, 1, type_=Type.uinteger), 1),
            symbols.ARGUMENT(symbols.NUMBER(3, 1, type_=Type.uinteger), 1))
        gl.SYMBOL_TABLE = SymbolTable()
        # Clears stderr and prepares for capturing it
        del config.OPTIONS.stderr
        config.OPTIONS(config.Action.ADD, name='stderr', default=StringIO())
        config.OPTIONS(config.Action.ADD_IF_NOT_DEFINED,
                       name='explicit',
                       type=bool,
                       default=False)

        self.aa1 = symbols.ARRAYACCESS(self.arr, self.arg, 2, 'fake-filename')