Skip to content

Commit

Permalink
xdsl: removed must_ prefix from parser methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLydike committed Jan 23, 2023
1 parent 9db3804 commit 868e509
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 182 deletions.
2 changes: 1 addition & 1 deletion tests/test_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_is_structurally_equivalent_incompatible_ir_nodes():
ctx.register_dialect(Cf)

parser = XDSLParser(ctx, program_func)
program: ModuleOp = parser.must_parse_operation()
program: ModuleOp = parser.parse_operation()

assert program.is_structurally_equivalent(program.regions[0]) == False
assert program.is_structurally_equivalent(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mlir_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def print_as_mlir_and_compare(test_prog: str, expected: str):
ctx.register_attr(ParamAttrWithCustomFormat)

parser = XDSLParser(ctx, test_prog)
module = parser.must_parse_operation()
module = parser.parse_operation()

res = StringIO()
printer = Printer(target=Printer.Target.MLIR, stream=res)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_int_list_parser(input: str, expected: list[int]):
ctx = MLContext()
parser = XDSLParser(ctx, input)

int_list = parser.must_parse_list_of(parser.try_parse_integer_literal, '')
int_list = parser.parse_list_of(parser.try_parse_integer_literal, '')
assert [int(span.text) for span in int_list] == expected


Expand All @@ -38,6 +38,6 @@ def test_dictionary_attr(data: dict[str, Attribute]):
ctx = MLContext()
ctx.register_dialect(Builtin)

attr = XDSLParser(ctx, text).must_parse_attribute()
attr = XDSLParser(ctx, text).parse_attribute()

assert attr.data == data
2 changes: 1 addition & 1 deletion tests/test_parser_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def check_error(prog: str, line: int, column: int, message: str):

parser = XDSLParser(ctx, prog)
with raises(ParseError) as e:
parser.must_parse_operation()
parser.parse_operation()

assert e.value.span

Expand Down
2 changes: 1 addition & 1 deletion tests/test_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def parse(cls, result_types: List[Attribute],

lhs = parser.expect(parser.try_parse_value_id,
'Expected SSA Value name here!')
parser.must_parse_characters(
parser.parse_characters(
"+", "Malformed operation format, expected `+`!")
rhs = parser.expect(parser.try_parse_value_id,
'Expected SSA Value name here!')
Expand Down
2 changes: 1 addition & 1 deletion xdsl/dialects/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class DictionaryAttr(GenericData[dict[str, Attribute]]):
def parse_parameter(parser: BaseParser) -> dict[str, Attribute]:
# force MLIR style parsing of attribute
from xdsl.parser import MLIRParser
return MLIRParser.must_parse_optional_attr_dict(parser)
return MLIRParser.parse_optional_attr_dict(parser)

@staticmethod
def print_parameter(data: dict[str, Attribute], printer: Printer) -> None:
Expand Down
6 changes: 3 additions & 3 deletions xdsl/dialects/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def print_parameters(self, printer: Printer) -> None:

@staticmethod
def parse_parameters(parser: BaseParser) -> list[Attribute]:
parser.must_parse_characters("<(", "LLVM Struct must start with `<(`")
params = parser.must_parse_list_of(
parser.parse_characters("<(", "LLVM Struct must start with `<(`")
params = parser.parse_list_of(
parser.try_parse_type,
"Malformed LLVM struct, expected attribute definition here!")
parser.must_parse_characters(
parser.parse_characters(
")>", "Unexpected input, expected end of LLVM struct!")
return [StringAttr.from_str(""), ArrayAttr.from_list(params)]

Expand Down
Loading

0 comments on commit 868e509

Please sign in to comment.