Skip to content

Commit

Permalink
Fix parsing issue of hex numbers in cast expr (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark1626 committed Jan 30, 2024
1 parent ffb3866 commit 84f5449
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ case class Parser(input: String) {
)
def hex[K: P]: P[Expr] =
positioned(
P("0x" ~/ CharIn("0-9a-fA-F").rep(1)).!.map((n: String) =>
P("0x" ~/ CharsWhileIn("0-9a-fA-F")).!.map((n: String) =>
EInt(BigInt(n.substring(2), 16), 16)
).opaque("hexademical")
)
Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/ParsingPositive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,9 @@ class ParsingTests extends org.scalatest.FunSuite {
parseAst("""
let x = (y as float);
""")
parseAst("""
let x = (0x9e3779b9 as ubit<32>);
let y = (023615674671 as ubit<32>);
""")
}
}

0 comments on commit 84f5449

Please sign in to comment.