Mirrors the layout of octive-lean: lakefile, justfile, gitignored
upstream clone, a top-level library module, and a Main entry point
that switches between REPL and file execution.
Module skeleton in GolangLean/:
Token, AST — real ports of go/token and go/ast
Scanner, Parser — stubs throwing notImpl, point at upstream
Value, Env, Error — runtime data shapes
Eval, Builtins, REPL — stubs that compile and run as a placeholder
PureEval, BigStep,
ValueEquiv — formal-semantics layer (mirroring octive-lean)
where cross-language proof eventually lives.
The proof layer is shaped identically to octive-lean's so that
theorems about Go semantics will share their form with the Octave
ones — that shared shape is the candidate for the future
cross-language core.
Upstream reference go-upstream/ (shallow clone of golang/go) is
gitignored.
27 lines
1.2 KiB
Text
27 lines
1.2 KiB
Text
namespace GolangLean
|
|
|
|
/-- Runtime / static errors produced anywhere in the Go toolchain. -/
|
|
inductive GoError where
|
|
| scan (msg : String) (line col : Nat) -- lexical
|
|
| parse (msg : String) (line col : Nat) -- syntactic
|
|
| typeErr (msg : String) -- static type-check
|
|
| runtime (msg : String) -- panic / runtime
|
|
| nilDeref -- nil-pointer dereference
|
|
| indexOOB (i n : Int) -- index out of range
|
|
| divByZero
|
|
| notImpl (what : String) -- placeholder for stubs
|
|
deriving Repr, Inhabited
|
|
|
|
def GoError.toString : GoError → String
|
|
| .scan m l c => s!"scan error: {m} ({l}:{c})"
|
|
| .parse m l c => s!"parse error: {m} ({l}:{c})"
|
|
| .typeErr m => s!"type error: {m}"
|
|
| .runtime m => s!"runtime error: {m}"
|
|
| .nilDeref => "runtime error: nil pointer dereference"
|
|
| .indexOOB i n => s!"runtime error: index out of range [{i}] with length {n}"
|
|
| .divByZero => "runtime error: integer divide by zero"
|
|
| .notImpl what => s!"not implemented: {what}"
|
|
|
|
instance : ToString GoError := ⟨GoError.toString⟩
|
|
|
|
end GolangLean
|