|
@@ -5,7 +5,7 @@ Date October 2014
|
|
|
A visitor that takes a tree returned by the parser parsing a grammar
|
|
|
and returns a structure that the parser can use to parse files written in that grammar
|
|
|
"""
|
|
|
-from hutnparser import * #we import the parser for constant, and the Tree Class
|
|
|
+from interface.HUTN.hutn_compiler.hutnparser import * #we import the parser for constant, and the Tree Class
|
|
|
from time import time
|
|
|
|
|
|
def dicToStr(dic):
|
|
@@ -128,7 +128,7 @@ class GrammarCompilerVisitor(Visitor):
|
|
|
elif rule == TOKEN_COLLECTION: #part of th grammar where tokens are defined as a def or collection
|
|
|
self.visitTokens(child)
|
|
|
else:
|
|
|
- print 'Encountered unexpected rule type in grammar rule. type: ', rule
|
|
|
+ print('Encountered unexpected rule type in grammar rule. type: ' + str(rule))
|
|
|
|
|
|
def visitRule(self,tree):
|
|
|
if self.isTree(tree):
|
|
@@ -152,7 +152,7 @@ class GrammarCompilerVisitor(Visitor):
|
|
|
elif rule == REMOVE:
|
|
|
rm = True
|
|
|
else:
|
|
|
- print 'Encountered unexpected rule type in rule definition. type: ', rule
|
|
|
+ print('Encountered unexpected rule type in rule definition. type: ' + str(rule))
|
|
|
|
|
|
if name and body:
|
|
|
mesg = msg
|
|
@@ -224,7 +224,7 @@ class GrammarCompilerVisitor(Visitor):
|
|
|
else:
|
|
|
rhs.append(r)
|
|
|
else:
|
|
|
- print 'Encountered unexpected rule type in tree RHS with head: ', item.head
|
|
|
+ print('Encountered unexpected rule type in tree RHS with head: ' + str(item.head))
|
|
|
elif self.isToken(item):
|
|
|
#print "TOKEN INNER in rule:", tree.head, "with name", item.head, " value", self.getTokenValue(item)
|
|
|
head = item.head
|
|
@@ -239,7 +239,7 @@ class GrammarCompilerVisitor(Visitor):
|
|
|
elif head == RPAR:
|
|
|
pass #the case is here because it is legal but doesn't require any other action than LPAR
|
|
|
else:
|
|
|
- print 'Encountered unexpected Token in RHS of kind: ', head
|
|
|
+ print('Encountered unexpected Token in RHS of kind: ' + str(head))
|
|
|
|
|
|
if operator == '.' or operator == '|':
|
|
|
rhs = [operator] + rhs
|