From 735267e1119adb868ff12a4444b5053e88d5a978 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Fri, 28 Feb 2020 13:42:03 +0000 Subject: [PATCH] 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 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26243 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/python/m5/util/grammar.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/python/m5/util/grammar.py b/src/python/m5/util/grammar.py index caf8a2e39..e09c989ee 100644 --- a/src/python/m5/util/grammar.py +++ b/src/python/m5/util/grammar.py @@ -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 -- 2.30.2