python: The new module has been removed in python3

new.instance was used to instantiate a method bypassing the __init__
interface This patch is doing things properly by importing the LRTable
so that the LRParser interface is respected

Change-Id: I0b0ce184ef5ac297af40289a2896962c9a967a71
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26243
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Giacomo Travaglini
2020-02-28 13:42:03 +00:00
parent 5d70afd3a9
commit 735267e111

View File

@@ -98,17 +98,16 @@ class Grammar(object):
raise AttributeError(
"argument must be a string, was '%s'" % type(f))
import new
lexer = self.lex.clone()
lexer.input(data)
self.lexers.append((lexer, source))
dict = {
'productions' : self.yacc.productions,
'action' : self.yacc.action,
'goto' : self.yacc.goto,
'errorfunc' : self.yacc.errorfunc,
}
parser = new.instance(ply.yacc.LRParser, dict)
lrtab = ply.yacc.LRTable()
lrtab.lr_productions = self.yacc.productions
lrtab.lr_action = self.yacc.action
lrtab.lr_goto = self.yacc.goto
parser = ply.yacc.LRParser(lrtab, self.yacc.errorfunc)
result = parser.parse(lexer=lexer, debug=debug, tracking=tracking)
self.lexers.pop()
return result