Skip to content

Commit

Permalink
Add support for 0.11.2 reveal format (close #35)
Browse files Browse the repository at this point in the history
  • Loading branch information
object-Object committed Dec 5, 2024
1 parent 6ef7e8a commit 3c531b0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/HexBug/hexdecode/revealparser.lark
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ _list_item: _non_pattern_iota | pattern+

pattern: "HexPattern" "(" DIRECTION ANGLES? ")"
| "<" DIRECTION ","? ANGLES? ">"
| "HexPattern" "[" DIRECTION "," ANGLES? "]"

vector: "(" NUMBER "," NUMBER "," NUMBER ")"

Expand Down
33 changes: 33 additions & 0 deletions test/hexdecode/test_revealparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def test_matrix(text: str, want: Iota):
("<east,>", PatternIota(Direction.EAST)),
("<east,w>", PatternIota(Direction.EAST, "w")),
("<east w>", PatternIota(Direction.EAST, "w")),
# Hex 0.11.2
("HexPattern[EAST, ]", PatternIota(Direction.EAST)),
("HexPattern[EAST, w]", PatternIota(Direction.EAST, "w")),
("HexPattern[EAST, aqweds]", PatternIota(Direction.EAST, "aqweds")),
],
)
def test_pattern(text: str, want: Iota):
Expand Down Expand Up @@ -133,6 +137,35 @@ def test_pattern(text: str, want: Iota):
0,
],
),
# latest.log (Hex 0.11.2)
(
"[HexPattern[EAST, ]HexPattern[SOUTH_WEST, w], 0.00]",
[
PatternIota(Direction.EAST),
PatternIota(Direction.SOUTH_WEST, "w"),
0,
],
),
(
"[HexPattern[EAST, ]HexPattern[EAST, w]HexPattern[NORTH_EAST, qaq]HexPattern[WEST, qqqaw]]",
[
PatternIota(Direction.EAST),
PatternIota(Direction.EAST, "w"),
PatternIota(Direction.NORTH_EAST, "qaq"),
PatternIota(Direction.WEST, "qqqaw"),
],
),
(
"[0.00, HexPattern[EAST, ], [HexPattern[NORTH_EAST, qaq]HexPattern[EAST, aa]]]",
[
0,
PatternIota(Direction.EAST),
[
PatternIota(Direction.NORTH_EAST, "qaq"),
PatternIota(Direction.EAST, "aa"),
],
],
),
],
)
def test_list(text: str, want: Iota):
Expand Down

0 comments on commit 3c531b0

Please sign in to comment.