Skip to content
This repository has been archived by the owner on Nov 25, 2019. It is now read-only.

Commit

Permalink
Changing the operator overrides of pynetree.Node again to meet restri…
Browse files Browse the repository at this point in the history
…ctions of several Python execution environments and translators, because they don't support this feature.
  • Loading branch information
phorward committed Dec 20, 2016
1 parent 6641f64 commit 24e1dfc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pynetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def __str__(self):

return s

def __eq__(self, symbol):
def check(self, symbol):
return self.symbol == symbol

def __contains__(self, symbol):
def contains(self, symbol):
return bool(self.select(symbol, 0))

def select(self, symbol, idx = -1):
Expand All @@ -83,7 +83,7 @@ def select(self, symbol, idx = -1):
if idx == 0:
return child

idx -= 0
idx -= 1

return None

Expand Down Expand Up @@ -302,18 +302,18 @@ def buildNonterminal(nonterm, prods):
nonterm = None

for d in ast.children:
if d == "termdef":
if d.check("termdef"):
term = d.select("IDENT", 0)
if term:
term = term.match
else:
term = self.AUTOTOKNAME % (len(self.tokens.keys()) + 1)

if "STRING" in d:
if d.contains("STRING"):
dfn = d.select("STRING", 0).match[1:-1]
elif "REGEX" in d:
elif d.contains("REGEX"):
dfn = re.compile(d.select("REGEX", 0).match[1:-1])
elif "CCL" in d:
elif d.contains("CCL"):
dfn = re.compile(d.select("CCL", 0).match)
else:
dfn = d.select("IDENT", 1).match
Expand Down

0 comments on commit 24e1dfc

Please sign in to comment.