Sha256: c009242d5f40362d7b9e53978a4219f8c226d6937e0a06a52ca7ecddd90c65e7

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

module Wool
  module SexpAnalysis
    # This is the base module for all annotations that can run on ASTs.
    # It includes all other annotation modules to provide all the
    # annotations to the Sexp class. These annotations are run at initialize
    # time for the Sexps and have access to a node and all of its child nodes,
    # all of which have been annotated. Synthesized attributes are fair game,
    # and adding inherited attributes to subnodes is also fair game.
    #
    # All annotations add O(V) to the parser runtime.
    #
    # This module also provides some helper methods to inject functionality into
    # the Sexp class. Since that's what an annotation is, I don't consider
    # this bad form!
    module BasicAnnotation
      def add_annotator(*args)
        SexpAnalysis::Sexp.annotations.concat args.map(&:new)
      end
      alias_method :add_annotators, :add_annotator
      def add_global_annotator(*args)
        SexpAnalysis.global_annotations.concat args.map(&:new)
      end
      alias_method :add_global_annotators, :add_global_annotator
      def add_property(*args)
        SexpAnalysis::Sexp.__send__(:attr_accessor, *args)
      end
      alias_method :add_properties, :add_property
    end
  end
end

Dir[File.expand_path(File.join(File.dirname(__FILE__), 'annotations', '**', '*.rb'))].each do |file|
  load file
end

Version data entries

1 entries across 1 versions & 1 rubygems

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