Skip to content

Commit

Permalink
Implemented suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
watermelonwolverine committed Jan 30, 2025
1 parent d24f9fd commit ae2ac64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions tests/dialects/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
AnyVectorType,
ArrayAttr,
BFloat16Type,
BoolAttr,
BytesAttr,
ComplexType,
DenseArrayBase,
Expand Down Expand Up @@ -188,9 +189,9 @@ def test_IntAttr___bool__():
assert IntAttr(1)


def test_IntegerAttr___bool__():
assert not IntegerAttr.from_bool(False)
assert IntegerAttr.from_bool(True)
def test_BoolAttr___bool__():
assert not BoolAttr.from_bool(False)
assert BoolAttr.from_bool(True)


def test_IntegerType_packing():
Expand Down
8 changes: 4 additions & 4 deletions xdsl/parser/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def parse_optional_integer(
"""
Parse an (possible negative) integer. The integer can either be
decimal or hexadecimal.
Optionally allow parsing of 'true' or 'false' into -1 and 0.
Optionally allow parsing of 'true' or 'false' into 1 and 0.
"""
# Parse true and false if needed
if allow_boolean:
Expand Down Expand Up @@ -78,7 +78,7 @@ def parse_integer(
"""
Parse an (possible negative) integer. The integer can
either be decimal or hexadecimal.
Optionally allow parsing of 'true' or 'false' into -1 and 0.
Optionally allow parsing of 'true' or 'false' into 1 and 0.
"""

return self.expect(
Expand Down Expand Up @@ -121,7 +121,7 @@ def parse_optional_number(
) -> int | float | None:
"""
Parse a (possibly negative) integer or float literal, if present.
Can optionally parse 'true' or 'false' into -1 and 0.
Can optionally parse 'true' or 'false' into 1 and 0.
"""

is_negative = self._parse_optional_token(MLIRTokenKind.MINUS) is not None
Expand Down Expand Up @@ -149,7 +149,7 @@ def parse_number(
) -> int | float:
"""
Parse a (possibly negative) integer or float literal.
Can optionally parse 'true' or 'false' into -1 and 0.
Can optionally parse 'true' or 'false' into 1 and 0.
"""
return self.expect(
lambda: self.parse_optional_number(allow_boolean=allow_boolean),
Expand Down

0 comments on commit ae2ac64

Please sign in to comment.