Class: Astrapi::Checker

Inherits:
Visitor show all
Defined in:
lib/checker.rb

Constant Summary

Constants included from Indent

Indent::INDENT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Visitor

#visit

Methods included from Indent

#dedent, #indent, #say

Instance Attribute Details

#mmObject

the checker checks :

  • that classes are uniquely defined

  • that attrs are uniquely defined withing a given class

  • that attrs types are defined in the metamodel



13
14
15
# File 'lib/checker.rb', line 13

def mm
  @mm
end

Instance Method Details

#check(ast) ⇒ Object



15
16
17
18
19
# File 'lib/checker.rb', line 15

def check ast
  @verbose=false
  @mm=ast
  ast.accept(self)
end

#visitArrayOf(arrayOf, args = nil) ⇒ Object



49
50
51
52
53
# File 'lib/checker.rb', line 49

def visitArrayOf arrayOf,args=nil
  indent "visitArrayOf"
  arrayOf.type.accept(self)
  dedent
end

#visitAttr(attr, args = nil) ⇒ Object



37
38
39
40
41
42
# File 'lib/checker.rb', line 37

def visitAttr attr,args=nil
  indent "visitAttr"
  attr.name.accept(self)
  attr.type.accept(self)
  dedent
end

#visitIdentifier(id, args = nil) ⇒ Object



55
56
57
58
59
# File 'lib/checker.rb', line 55

def visitIdentifier id,args=nil
  indent "visitIdentifier"
  say " - #{id}"
  dedent
end

#visitKlass(klass, args = nil) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/checker.rb', line 28

def visitKlass klass,args=nil
  indent "visitKlass #{klass.name}"
  if klass.inheritance

  end
  klass.attrs.each{|attr| attr.accept(self)}
  dedent
end

#visitModule(modul, args = nil) ⇒ Object



21
22
23
24
25
26
# File 'lib/checker.rb', line 21

def visitModule modul,args=nil
  indent "visitModule"
  name=modul.name.accept(self)
  modul.classes.each{|k| k.accept(self)}
  dedent
end

#visitType(type, args = nil) ⇒ Object



44
45
46
47
# File 'lib/checker.rb', line 44

def visitType type,args=nil
  indent "visitType"
  dedent
end