<commit_before>package ast

type Visitor interface {
	Visit(node Node) (w Visitor)
}

func Walk(v Visitor, node Node) {
	if v = v.Visit(node); v == nil {
		return
	}

	switch n := node.(type) {
	case *Argument:
		Walk(v, n.Name)
	case *Assigment:
		Walk(v, n.Left)
		Walk(v, n.Right)
	case *BinaryExpression:
		Walk(v, n.Left)
		Walk(v, n.Right)
	case *Block:
		for _, nb := range n.Body {
			Walk(v, nb)
		}
	case *CallArgument:
		Walk(v, n.Expression)
	case *ComparisonExpression:
		Walk(v, n.Left)
		Walk(v, n.Right)
	case *Comment:
		// Nothing to do here
	case *File:
		for _, nb := range n.Body {
			Walk(v, nb)
		}
	case *ForLoop:
		Walk(v, n.Init)
		Walk(v, n.Condition)
		Walk(v, n.After)
		Walk(v, n.Block)
	case *FunctionCall:
		Walk(v, n.Callee)
		for _, nb := range n.Arguments {
			Walk(v, nb)
		}
	case *FunctionDeclaration:
		for _, nb := range n.Arguments {
			Walk(v, nb)
		}
		if n.Block != nil {
			Walk(v, n.Block)
		}
	case *IfStatement:
		if n.Condition != nil {
			Walk(v, n.Condition)
		}
		if n.Block != nil {
			Walk(v, n.Block)
		}
		if n.Else != nil {
			Walk(v, n.Else)
		}
	case *Macro:
		// TODO macro
	case *MemberExpression:
		Walk(v, n.Target)
	case *MultiVariableDeclaration:
		for _, d := range n.Declarations {
			Walk(v, d)
		}
	case *UnaryExpression:
		Walk(v, n.Expression)
	case *VariableDeclaration:
		Walk(v, n.DefaultValue)
	case *ValueExpression:
	default:
		panic("Unknown node type")
	}
}<commit_msg>Walk default values and var decl names<commit_after>package ast

type Visitor interface {
	Visit(node Node) (w Visitor)
}

func Walk(v Visitor, node Node) {
	if node == nil {
		return
	}
	if v = v.Visit(node); v == nil {
		return
	}

	switch n := node.(type) {
	case *Argument:
		Walk(v, n.Name)
		// TODO walk type
		Walk(v, n.DefaultValue)
	case *Assigment:
		Walk(v, n.Left)
		Walk(v, n.Right)
	case *BinaryExpression:
		Walk(v, n.Left)
		Walk(v, n.Right)
	case *Block:
		for _, nb := range n.Body {
			Walk(v, nb)
		}
	case *CallArgument:
		Walk(v, n.Expression)
	case *ComparisonExpression:
		Walk(v, n.Left)
		Walk(v, n.Right)
	case *Comment:
		// Nothing to do here
	case *File:
		for _, nb := range n.Body {
			Walk(v, nb)
		}
	case *ForLoop:
		Walk(v, n.Init)
		Walk(v, n.Condition)
		Walk(v, n.After)
		Walk(v, n.Block)
	case *FunctionCall:
		Walk(v, n.Callee)
		for _, nb := range n.Arguments {
			Walk(v, nb)
		}
	case *FunctionDeclaration:
		for _, nb := range n.Arguments {
			Walk(v, nb)
		}
		if n.Block != nil {
			Walk(v, n.Block)
		}
	case *IfStatement:
		if n.Condition != nil {
			Walk(v, n.Condition)
		}
		if n.Block != nil {
			Walk(v, n.Block)
		}
		if n.Else != nil {
			Walk(v, n.Else)
		}
	case *Macro:
		// TODO macro
	case *MemberExpression:
		Walk(v, n.Target)
	case *MultiVariableDeclaration:
		for _, d := range n.Declarations {
			Walk(v, d)
		}
	case *UnaryExpression:
		Walk(v, n.Expression)
	case *VariableDeclaration:
		Walk(v, n.Name)
		// TODO walk type
		Walk(v, n.DefaultValue)
	case *ValueExpression:
	default:
		panic("Unknown node type")
	}
}
{'fraction_non_alphanumeric': 0.15024711696869852, 'fraction_numerical': 0.0, 'mean_word_length': 2.973821989528796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5748973', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1249, 'n_words': 322}