Introduce [spa_e| ... ] for Expr and [spa| ... ] for Stmt, scoped to the Spa namespace via a dedicated syntax category and macro_rules. This removes the deeply nested .andThen / .basic (.assign ...) boilerplate when writing programs; Main.lean's test programs are rewritten to use it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
642 B
Lean4
36 lines
642 B
Lean4
import Spa.Analysis.Sign
|
|
import Spa.Analysis.Constant
|
|
import Spa.Language.Notation
|
|
|
|
namespace Spa
|
|
|
|
def testCode : Stmt := [obj_stmt|
|
|
zero := 0;
|
|
pos := zero + 1;
|
|
neg := zero - 1;
|
|
unknown := pos + neg
|
|
]
|
|
|
|
def testCodeCond₁ : Stmt := [obj_stmt|
|
|
var := 1;
|
|
if var {
|
|
var := var + 1
|
|
} else {
|
|
var := var - 1;
|
|
var := 1
|
|
}
|
|
]
|
|
|
|
def testCodeCond₂ : Stmt := [obj_stmt|
|
|
var := 1;
|
|
if var { x := 1 } else { noop }
|
|
]
|
|
|
|
def testProgram : Program := ⟨testCode⟩
|
|
|
|
end Spa
|
|
|
|
def main : IO Unit :=
|
|
IO.println (Spa.ConstAnalysis.output Spa.testProgram ++ "\n" ++
|
|
Spa.SignAnalysis.output Spa.testProgram)
|