src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

walker.go (503B)


      1 package ini
      2 
      3 // Walk will traverse the AST using the v, the Visitor.
      4 func Walk(tree []AST, v Visitor) error {
      5 	for _, node := range tree {
      6 		switch node.Kind {
      7 		case ASTKindExpr,
      8 			ASTKindExprStatement:
      9 
     10 			if err := v.VisitExpr(node); err != nil {
     11 				return err
     12 			}
     13 		case ASTKindStatement,
     14 			ASTKindCompletedSectionStatement,
     15 			ASTKindNestedSectionStatement,
     16 			ASTKindCompletedNestedSectionStatement:
     17 
     18 			if err := v.VisitStatement(node); err != nil {
     19 				return err
     20 			}
     21 		}
     22 	}
     23 
     24 	return nil
     25 }