# Path: baslexer.py
# class BasLexer(object):
#     def build(self,**kwargs):
#         self.lexer = lex.lex(module=self, **kwargs)
#         return self.lexer
# 
#     tokens = [
#         'NAME', 'UUID', 'VAR', 'TAG', 'SPATIAL',
#         'UPSTREAM', 'DOWNSTREAM', 'EQUALS', 'LASTVALUE',
#         'LPAREN', 'RPAREN',
#         'UPSTREAMIMM', 'DOWNSTREAMIMM'
#         ]
# 
#     t_UPSTREAM    = r'>'
#     t_DOWNSTREAM  = r'<'
#     t_UPSTREAMIMM    = r'>>'
#     t_DOWNSTREAMIMM  = r'<<'
#     t_LPAREN      = r'\('
#     t_RPAREN      = r'\)'
#     #t_LBRACK      = r'\['
#     #t_RBRACK      = r'\]'
#     t_EQUALS      = r'='
#     t_ignore      = ' \t'
# 
#     def t_NAME(self,t):
#         r'\$[^!][\w\-\:\_\s]+'
#         t.value = t.value.strip()
#         return t
# 
#     def t_TAG(self,t):
#         r'(\.|\#|\&)([^!]?[A-Z_ ]+)?[ ]?'
#         t.value = t.value.strip()
#         return t
# 
#     def t_SPATIAL(self,t):
#         r'!\#?([\w\-\:\_\s]+)?'
#         t.value = t.value.strip()
#         return t
# 
#     def t_UUID(self,t):
#         r'(\%|\^)[^!]?[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}[ ]?'
#         t.value = t.value.strip()
#         return t
# 
#     def t_VAR(self,t):
#         r'\@[^!]?[a-zA-Z_][a-zA-Z0-9_]*[ ]?'
#         t.value = t.value.strip()
#         return t
# 
#     def t_LASTVALUE(self,t):
#         r'\b\_\b'
#         t.value = t.value.strip()
#         return t
# 
#     def t_error(self, t):
#         print "Illegal character '%s'" % t.value[0]
#         t.lexer.skip(1)


from baslexer import BasLexer
from collections import deque
from node import *
import ply.yacc as yacc
import itertools
import gis
import sdh_demo as sdh
              queue.appendleft(n)
      #search the relatives of the current node according to relative_fxn
      #for each relative, if we haven't traversed it, add it to the queue
      for n in relative_fxn(current):
        if n not in already_visited:
          already_visited.append(n)
          queue.appendleft(n)
      #if current has an external container, add it to the queue
      if current.external_parents and direction == "predecessors":
        for p in current.external_parents:
          if p not in already_visited:
            already_visited.append(p)
            queue.appendleft(p)
      elif current.external_childs and direction == "successors":
        for c in current.external_childs:
          if c not in already_visited:
            already_visited.append(c)
            queue.appendleft(c)
      #finally, add the current's container to the queue
      if not isinstance(current.container, Relational):
        if current.container not in queue and current.container not in already_visited:
          already_visited.append(current.container)
          queue.appendleft(current.container)
    return None

class BasParser(object):
    basvars = dict()
    def build(self):
        return yacc.yacc(module=self)


# Path: baslexer.py
# class BasLexer(object):
#     def build(self,**kwargs):
#         self.lexer = lex.lex(module=self, **kwargs)
#         return self.lexer
# 
#     tokens = [
#         'NAME', 'UUID', 'VAR', 'TAG', 'SPATIAL',
#         'UPSTREAM', 'DOWNSTREAM', 'EQUALS', 'LASTVALUE',
#         'LPAREN', 'RPAREN',
#         'UPSTREAMIMM', 'DOWNSTREAMIMM'
#         ]
# 
#     t_UPSTREAM    = r'>'
#     t_DOWNSTREAM  = r'<'
#     t_UPSTREAMIMM    = r'>>'
#     t_DOWNSTREAMIMM  = r'<<'
#     t_LPAREN      = r'\('
#     t_RPAREN      = r'\)'
#     #t_LBRACK      = r'\['
#     #t_RBRACK      = r'\]'
#     t_EQUALS      = r'='
#     t_ignore      = ' \t'
# 
#     def t_NAME(self,t):
#         r'\$[^!][\w\-\:\_\s]+'
#         t.value = t.value.strip()
#         return t
# 
#     def t_TAG(self,t):
#         r'(\.|\#|\&)([^!]?[A-Z_ ]+)?[ ]?'
#         t.value = t.value.strip()
#         return t
# 
#     def t_SPATIAL(self,t):
#         r'!\#?([\w\-\:\_\s]+)?'
#         t.value = t.value.strip()
#         return t
# 
#     def t_UUID(self,t):
#         r'(\%|\^)[^!]?[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}[ ]?'
#         t.value = t.value.strip()
#         return t
# 
#     def t_VAR(self,t):
#         r'\@[^!]?[a-zA-Z_][a-zA-Z0-9_]*[ ]?'
#         t.value = t.value.strip()
#         return t
# 
#     def t_LASTVALUE(self,t):
#         r'\b\_\b'
#         t.value = t.value.strip()
#         return t
# 
#     def t_error(self, t):
#         print "Illegal character '%s'" % t.value[0]
#         t.lexer.skip(1)


# Path: basparser.py
from baslexer import BasLexer
from collections import deque
from node import *
import ply.yacc as yacc
import itertools
import gis
import sdh_demo as sdh

              queue.appendleft(n)
      #search the relatives of the current node according to relative_fxn
      #for each relative, if we haven't traversed it, add it to the queue
      for n in relative_fxn(current):
        if n not in already_visited:
          already_visited.append(n)
          queue.appendleft(n)
      #if current has an external container, add it to the queue
      if current.external_parents and direction == "predecessors":
        for p in current.external_parents:
          if p not in already_visited:
            already_visited.append(p)
            queue.appendleft(p)
      elif current.external_childs and direction == "successors":
        for c in current.external_childs:
          if c not in already_visited:
            already_visited.append(c)
            queue.appendleft(c)
      #finally, add the current's container to the queue
      if not isinstance(current.container, Relational):
        if current.container not in queue and current.container not in already_visited:
          already_visited.append(current.container)
          queue.appendleft(current.container)
    return None

class BasParser(object):
    basvars = dict()
    def build(self):
        return yacc.yacc(module=self)


    tokens = BasLexer.tokens