@@ -814,7 +814,11 @@ These parsers can interperet hex-encoded strings as `Int`s, `ByteArray`s, and `M
814
814
// -------------------------------------------------------------
815
815
rule #parseByteStack(S) => #parseHexBytes(replaceAll(S, "0x", ""))
816
816
rule #parseHexBytes("") => .ByteArray
817
- rule #parseHexBytes(S) => Int2Bytes(1, #parseHexWord(substrString(S, 0, 2)), BE) +Bytes #parseHexBytes(substrString(S, 2, lengthString(S))) requires lengthString(S) >=Int 2
817
+ rule #parseHexBytes(S) => #parseHexBytes("0" +String S)
818
+ requires notBool lengthString(S) modInt 2 ==Int 0
819
+ rule #parseHexBytes(S) => Int2Bytes(1, #parseHexWord(substrString(S, 0, 2)), BE) +Bytes #parseHexBytes(substrString(S, 2, lengthString(S)))
820
+ requires lengthString(S) modInt 2 ==Int 0
821
+ andBool lengthString(S) >Int 0
818
822
819
823
rule #parseByteStackRaw(S) => String2Bytes(S)
820
824
```
@@ -826,7 +830,11 @@ These parsers can interperet hex-encoded strings as `Int`s, `ByteArray`s, and `M
826
830
// -------------------------------------------------------------
827
831
rule #parseByteStack(S) => #parseHexBytes(replaceAll(S, "0x", ""))
828
832
rule #parseHexBytes("") => .WordStack
829
- rule #parseHexBytes(S) => #parseHexWord(substrString(S, 0, 2)) : #parseHexBytes(substrString(S, 2, lengthString(S))) requires lengthString(S) >=Int 2
833
+ rule #parseHexBytes(S) => #parseHexBytes("0" +String S)
834
+ requires notBool lengthString(S) modInt 2 ==Int 0
835
+ rule #parseHexBytes(S) => #parseHexWord(substrString(S, 0, 2)) : #parseHexBytes(substrString(S, 2, lengthString(S)))
836
+ requires lengthString(S) modInt 2 ==Int 0
837
+ andBool lengthString(S) >Int 0
830
838
831
839
rule #parseByteStackRaw(S) => ordChar(substrString(S, 0, 1)) : #parseByteStackRaw(substrString(S, 1, lengthString(S))) requires lengthString(S) >=Int 1
832
840
rule #parseByteStackRaw("") => .WordStack
0 commit comments