Module: Wool::SexpAnalysis::BasicAnnotation

Included in:
NextPrevAnnotation, ParentAnnotation, ScopeAnnotation
Defined in:
lib/wool/analysis/annotations.rb

Overview

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!

Instance Method Summary collapse

Instance Method Details

#add_annotator(*args) ⇒ Object Also known as: add_annotators



16
17
18
# File 'lib/wool/analysis/annotations.rb', line 16

def add_annotator(*args)
  SexpAnalysis::Sexp.annotations.concat args.map(&:new)
end

#add_global_annotator(*args) ⇒ Object Also known as: add_global_annotators



20
21
22
# File 'lib/wool/analysis/annotations.rb', line 20

def add_global_annotator(*args)
  SexpAnalysis.global_annotations.concat args.map(&:new)
end

#add_property(*args) ⇒ Object Also known as: add_properties



24
25
26
# File 'lib/wool/analysis/annotations.rb', line 24

def add_property(*args)
  SexpAnalysis::Sexp.__send__(:attr_accessor, *args)
end