Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Make a few print and parse function public #1301

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions xdsl/parser/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def _parse_generic_operation(self, op_type: type[Operation]) -> Operation:
dictionary-attribute ::= `{` (attribute-entry (`,` attribute-entry)*)? `}`
"""
# Parse arguments
args = self._parse_op_args_list()
args = self.parse_op_args_list()

# Parse successors
successors = self.parse_optional_successors()
Expand Down Expand Up @@ -887,7 +887,7 @@ def parse_successors(self) -> list[Block]:
lambda: self.expect(self.parse_successor, "block-id expected"),
)

def _parse_op_args_list(self) -> list[UnresolvedOperand]:
def parse_op_args_list(self) -> list[UnresolvedOperand]:
"""
Parse a list of arguments with format:
args-list ::= `(` value-use-list? `)`
Expand Down
10 changes: 5 additions & 5 deletions xdsl/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def print_ssa_value(self, value: SSAValue) -> None:

self.print(f"%{name}")

def _print_operand(self, operand: SSAValue) -> None:
def print_operand(self, operand: SSAValue) -> None:
self.print_ssa_value(operand)

def print_block_name(self, block: Block) -> None:
Expand Down Expand Up @@ -306,16 +306,16 @@ def print_regions(self, regions: list[Region]) -> None:
self.print_list(regions, self.print_region)
self.print(")")

def _print_operands(self, operands: Sequence[SSAValue]) -> None:
def print_operands(self, operands: Sequence[SSAValue]) -> None:
if len(operands) == 0:
self.print("()")
return

self.print("(")
self._print_operand(operands[0])
self.print_operand(operands[0])
for operand in operands[1:]:
self.print(", ")
self._print_operand(operand)
self.print_operand(operand)
self.print(")")

def print_paramattr_parameters(
Expand Down Expand Up @@ -660,7 +660,7 @@ def print_op_attributes(self, attributes: dict[str, Attribute]) -> None:
self.print("}")

def print_op_with_default_format(self, op: Operation) -> None:
self._print_operands(op.operands)
self.print_operands(op.operands)
self.print_successors(op.successors)

self.print_regions(op.regions)
Expand Down