MCPcopy Create free account
hub / github.com/argumentcomputer/ix / hash_syntax

Function hash_syntax

crates/common/src/env.rs:687–718  ·  view source on GitHub ↗
(syn: &Syntax, hasher: &mut blake3::Hasher)

Source from the content-addressed store, hash-verified

685 }
686 },
687 }
688}
689
690/// A Lean 4 concrete syntax tree node.
691#[derive(Debug, PartialEq, Eq, Clone, Hash)]
692pub enum Syntax {
693 /// Placeholder for missing syntax.
694 Missing,
695 /// An interior syntax node with a kind name and child nodes.
696 Node(SourceInfo, Name, Vec<Syntax>),
697 /// An atomic token (keyword, symbol, etc.).
698 Atom(SourceInfo, String),
699 /// An identifier with optional pre-resolved references.
700 Ident(SourceInfo, Substring, Name, Vec<SyntaxPreresolved>),
701}
702
703fn hash_syntax(syn: &Syntax, hasher: &mut blake3::Hasher) {
704 hasher.update(&[MSYN]);
705 match syn {
706 Syntax::Missing => {
707 hasher.update(&[0]);
708 },
709 Syntax::Node(info, kind, args) => {
710 hasher.update(&[1]);
711 hash_source_info(info, hasher);
712 hasher.update(kind.get_hash().as_bytes());
713 hasher.update(&Nat::from(args.len() as u64).to_le_bytes());
714 for arg in args {
715 hash_syntax(arg, hasher);
716 }
717 },
718 Syntax::Atom(info, val) => {
719 hasher.update(&[2]);
720 hash_source_info(info, hasher);
721 hasher.update(val.as_bytes());

Callers 1

hash_data_valueFunction · 0.85

Calls 6

hash_source_infoFunction · 0.85
hash_substringFunction · 0.85
hash_syntax_preresolvedFunction · 0.85
as_bytesMethod · 0.80
get_hashMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected