Skip to main content

Module normalizer

Module normalizer 

Source
Expand description

Canonical normalizer — converts ICL to deterministic canonical form

The normalizer transforms an ICL contract into its canonical representation. This is the single deterministic form used for hashing, comparison, and storage.

§Pipeline

ICL text → parse → AST → normalize_ast → serialize_canonical → SHA-256

§Guarantees

  • Idempotent: normalize(normalize(x)) == normalize(x)
  • Deterministic: same input always produces same output
  • Unique: each distinct contract has one canonical form
  • Semantic preserving: no information loss

Functions§

compute_semantic_hash
Compute SHA-256 semantic hash of a normalized AST
normalize
Normalize ICL text to canonical form
normalize_ast
Normalize a parsed AST to canonical form (sorted, expanded, hashed)
normalize_contract
Normalize a parsed Contract struct to canonical form
serialize_canonical
Serialize a ContractNode AST to canonical ICL text