From: Dmitry Selyutin Date: Tue, 9 Jan 2024 15:49:56 +0000 (+0300) Subject: oppc: decouple call name class X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de5aa1112c255b6c74e48fd29eb971d7c4a2a238;p=openpower-isa.git oppc: decouple call name class --- diff --git a/src/openpower/oppc/pc_ast.py b/src/openpower/oppc/pc_ast.py index d139d2db..9812107c 100644 --- a/src/openpower/oppc/pc_ast.py +++ b/src/openpower/oppc/pc_ast.py @@ -67,10 +67,6 @@ class Sequence(Node, tuple, metaclass=SequenceMeta): return f"{hex(id(self))}@{self.__class__.__name__}({repr(list(self))})" -class Arguments(Sequence): - pass - - class Scope(Sequence): pass @@ -231,7 +227,13 @@ class RParenthesis(Token): class Call(Dataclass): - name: Symbol + class Name(Symbol): + pass + + class Arguments(Sequence): + pass + + name: Name args: Arguments diff --git a/src/openpower/oppc/pc_parser.py b/src/openpower/oppc/pc_parser.py index 03adc635..33d2d8db 100644 --- a/src/openpower/oppc/pc_parser.py +++ b/src/openpower/oppc/pc_parser.py @@ -425,13 +425,15 @@ class Parser: node = p[2] while isinstance(node.subject, attribute_or_subscript): node = node.subject - if isinstance(node.subject, pc_ast.Arguments): - node.subject = pc_ast.Call(name=p[1], args=node.subject) + if isinstance(node.subject, pc_ast.Call.Arguments): + name = pc_ast.Call.Name(str(p[1])) + node.subject = pc_ast.Call(name=name, args=node.subject) else: node.subject = p[1] p[0] = p[2] - elif isinstance(p[2], pc_ast.Arguments): - p[0] = pc_ast.Call(name=p[1], args=p[2]) + elif isinstance(p[2], pc_ast.Call.Arguments): + name = pc_ast.Call.Name(str(p[1])) + p[0] = pc_ast.Call(name=name, args=p[2]) else: raise NotImplementedError() @@ -514,7 +516,7 @@ class Parser: | LPAR RPAR """ if len(p) == 3: - p[0] = pc_ast.Arguments() + p[0] = pc_ast.Call.Arguments() else: p[0] = p[2] @@ -591,9 +593,9 @@ class Parser: | argument """ if len(p) == 4: - p[0] = pc_ast.Arguments(p[1] + (p[3],)) + p[0] = pc_ast.Call.Arguments(p[1] + (p[3],)) else: - p[0] = pc_ast.Arguments([p[1]]) + p[0] = pc_ast.Call.Arguments([p[1]]) # argument: test [gen_for] | test '=' test # Really [keyword '='] test def p_argument(self, p):