Skip to content

Commit 8faa0a8

Browse files
committed
feat: overflow support
1 parent 751ea34 commit 8faa0a8

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Leanwuzla/Parser.lean

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,45 @@ where
352352
let (α, x) ← parseTerm x
353353
let w ← getBitVecWidth α
354354
return (α, mkApp3 (.const ``BitVec.rotateRight []) (mkNatLit w) x (mkNatLit i))
355+
if let sexp!{(bvnego {x})} := e then
356+
let (α, x) ← parseTerm x
357+
let w ← getBitVecWidth α
358+
return (mkBool, mkApp2 (.const ``BitVec.negOverflow []) (mkNatLit w) x)
359+
if let sexp!{(bvuaddo {x} {y})} := e then
360+
let (α, x) ← parseTerm x
361+
let (_, y) ← parseTerm y
362+
let w ← getBitVecWidth α
363+
return (mkBool, mkApp3 (.const ``BitVec.uaddOverflow []) (mkNatLit w) x y)
364+
if let sexp!{(bvsaddo {x} {y})} := e then
365+
let (α, x) ← parseTerm x
366+
let (_, y) ← parseTerm y
367+
let w ← getBitVecWidth α
368+
return (mkBool, mkApp3 (.const ``BitVec.saddOverflow []) (mkNatLit w) x y)
369+
if let sexp!{(bvumulo {x} {y})} := e then
370+
let (α, x) ← parseTerm x
371+
let (_, y) ← parseTerm y
372+
let w ← getBitVecWidth α
373+
return (mkBool, mkApp3 (.const ``BitVec.umulOverflow []) (mkNatLit w) x y)
374+
if let sexp!{(bvsmulo {x} {y})} := e then
375+
let (α, x) ← parseTerm x
376+
let (_, y) ← parseTerm y
377+
let w ← getBitVecWidth α
378+
return (mkBool, mkApp3 (.const ``BitVec.smulOverflow []) (mkNatLit w) x y)
379+
if let sexp!{(bvusubo {x} {y})} := e then
380+
let (α, x) ← parseTerm x
381+
let (_, y) ← parseTerm y
382+
let w ← getBitVecWidth α
383+
return (mkBool, mkApp3 (.const ``BitVec.usubOverflow []) (mkNatLit w) x y)
384+
if let sexp!{(bvssubo {x} {y})} := e then
385+
let (α, x) ← parseTerm x
386+
let (_, y) ← parseTerm y
387+
let w ← getBitVecWidth α
388+
return (mkBool, mkApp3 (.const ``BitVec.ssubOverflow []) (mkNatLit w) x y)
389+
if let sexp!{(bvsdivo {x} {y})} := e then
390+
let (α, x) ← parseTerm x
391+
let (_, y) ← parseTerm y
392+
let w ← getBitVecWidth α
393+
return (mkBool, mkApp3 (.const ``BitVec.sdivOverflow []) (mkNatLit w) x y)
355394
if let some r ← parseVar? e then
356395
return r
357396
if let some ⟨w, x⟩ := parseBVLiteral? s then

0 commit comments

Comments
 (0)