summaryrefslogtreecommitdiffstats
path: root/Tools/cases_generator/parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/cases_generator/parser.py')
-rw-r--r--Tools/cases_generator/parser.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/Tools/cases_generator/parser.py b/Tools/cases_generator/parser.py
index 7bf45a3..56920f2 100644
--- a/Tools/cases_generator/parser.py
+++ b/Tools/cases_generator/parser.py
@@ -136,10 +136,15 @@ class Family(Node):
size: str # Variable giving the cache size in code units
members: list[str]
+@dataclass
+class Pseudo(Node):
+ name: str
+ targets: list[str] # opcodes this can be replaced by
+
class Parser(PLexer):
@contextual
- def definition(self) -> InstDef | Super | Macro | Family | None:
+ def definition(self) -> InstDef | Super | Macro | Family | Pseudo | None:
if inst := self.inst_def():
return inst
if super := self.super_def():
@@ -148,6 +153,8 @@ class Parser(PLexer):
return macro
if family := self.family_def():
return family
+ if pseudo := self.pseudo_def():
+ return pseudo
@contextual
def inst_def(self) -> InstDef | None:
@@ -364,6 +371,23 @@ class Parser(PLexer):
)
return None
+ @contextual
+ def pseudo_def(self) -> Pseudo | None:
+ if (tkn := self.expect(lx.IDENTIFIER)) and tkn.text == "pseudo":
+ size = None
+ if self.expect(lx.LPAREN):
+ if tkn := self.expect(lx.IDENTIFIER):
+ if self.expect(lx.RPAREN):
+ if self.expect(lx.EQUALS):
+ if not self.expect(lx.LBRACE):
+ raise self.make_syntax_error("Expected {")
+ if members := self.members():
+ if self.expect(lx.RBRACE) and self.expect(lx.SEMI):
+ return Pseudo(
+ tkn.text, members
+ )
+ return None
+
def members(self) -> list[str] | None:
here = self.getpos()
if tkn := self.expect(lx.IDENTIFIER):