Ejemplo n.º 1
0
 def test_nested_scope(self):
     string = "(lambda x. x) ((lambda x. x) (lambda z. (lambda x. x) x))"
     tokens = Lexer.tokenize(string)
     self.assertEqual(
         Parser.scope(tokens),
         [['lambda', 'x', '.', 'x'],
          [['lambda', 'x', '.', 'x'],
           ['lambda', 'z', '.', ['lambda', 'x', '.', 'x'], 'x']]])
 def test_nested_scope(self):
     string = "(lambda x. x) ((lambda x. x) (lambda z. (lambda x. x) x))"
     tokens = Lexer.tokenize(string)
     self.assertEqual(Parser.scope(tokens),
                      [['lambda', 'x', '.', 'x'],
                       [['lambda', 'x', '.', 'x'], ['lambda', 'z', '.',
                                                    ['lambda', 'x',
                                                     '.', 'x'], 'x']]])
Ejemplo n.º 3
0
 def test_scope3(self):
     newTokens = ['(', 'lambda', 'x', '.', 'x', 'y', ')', 't']
     self.assertEqual(Parser.scope(newTokens),
                      [['lambda', 'x', '.', 'x', 'y'], 't'])
Ejemplo n.º 4
0
 def test_scope2(self):
     self.assertEqual(Parser.scope(self.id_tokens),
                      [['lambda', 'x', '.', 'x']])
Ejemplo n.º 5
0
 def test_scope1(self):
     self.assertEqual(Parser.scope(self.application_tokens),
                      [['lambda', 'x', '.', 'x'], 't'])
 def test_scope3(self):
     newTokens = ['(', 'lambda', 'x', '.', 'x', 'y', ')', 't']
     self.assertEqual(Parser.scope(newTokens),
                      [['lambda', 'x', '.', 'x', 'y'], 't'])
 def test_scope2(self):
     self.assertEqual(Parser.scope(self.id_tokens),
                      [['lambda', 'x', '.', 'x']])
 def test_scope1(self):
     self.assertEqual(Parser.scope(self.application_tokens),
                      [['lambda', 'x', '.', 'x'], 't'])