Sha256: 4a4bd98fa81d4720468a4718514247eda7cc594ff53e28a08aa68dee7061c0f8

Contents?: true

Size: 575 Bytes

Versions: 1

Compression:

Stored size: 575 Bytes

Contents

module Wool
  module SexpAnalysis
    # This is a simple inherited attribute applied to each node,
    # giving a pointer to that node's parent. That way AST traversal
    # is easier.
    module ParentAnnotation
      extend BasicAnnotation
      add_property :parent
      
      # This is the annotator for the parent annotation.
      class Annotator
        def annotate!(root)
          root.parent = nil
          root.children.select {|x| SexpAnalysis::Sexp === x}.each {|sexp| sexp.parent = root}
        end
      end
      add_annotator Annotator
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wool-0.5.1 lib/wool/analysis/annotations/parent_annotation.rb