You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Add nonterminal node in extractInfo
This commit is contained in:
@@ -82,7 +82,7 @@ from spark_parser.ast import GenericASTTraversalPruningException
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
NodeInfo = namedtuple("NodeInfo", "node start finish")
|
NodeInfo = namedtuple("NodeInfo", "node start finish")
|
||||||
ExtractInfo = namedtuple("ExtractInfo",
|
ExtractInfo = namedtuple("ExtractInfo",
|
||||||
"lineNo lineStartOffset markerLine selectedLine selectedText")
|
"lineNo lineStartOffset markerLine selectedLine selectedText nonterminal")
|
||||||
|
|
||||||
TABLE_DIRECT_FRAGMENT = {
|
TABLE_DIRECT_FRAGMENT = {
|
||||||
'break_stmt': ( '%|%rbreak\n', ),
|
'break_stmt': ( '%|%rbreak\n', ),
|
||||||
@@ -1215,10 +1215,16 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
|
|
||||||
if elided: selectedLine += ' ...'
|
if elided: selectedLine += ' ...'
|
||||||
|
|
||||||
|
if isinstance(nodeInfo, AST):
|
||||||
|
nonterminal = nodeInfo[0]
|
||||||
|
else:
|
||||||
|
nonterminal = nodeInfo.node
|
||||||
|
|
||||||
return ExtractInfo(lineNo = len(lines), lineStartOffset = lineStart,
|
return ExtractInfo(lineNo = len(lines), lineStartOffset = lineStart,
|
||||||
markerLine = markerLine,
|
markerLine = markerLine,
|
||||||
selectedLine = selectedLine,
|
selectedLine = selectedLine,
|
||||||
selectedText = selectedText)
|
selectedText = selectedText,
|
||||||
|
nonterminal = nonterminal)
|
||||||
|
|
||||||
def extract_line_info(self, name, offset):
|
def extract_line_info(self, name, offset):
|
||||||
if (name, offset) not in list(self.offsets.keys()):
|
if (name, offset) not in list(self.offsets.keys()):
|
||||||
|
Reference in New Issue
Block a user