Class: Mulang::Language::External

Inherits:
Base
  • Object
show all
Defined in:
lib/mulang/language.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#ast_analysis, #identifiers, #identifiers_analysis, #normalization_options, #transformed_asts, #transformed_asts_analysis

Constructor Details

#initialize(language_name = nil, &tool) ⇒ External

Returns a new instance of External.



81
82
83
84
# File 'lib/mulang/language.rb', line 81

def initialize(language_name = nil, &tool)
  @name = language_name
  @tool = block_given? ? tool : proc { |it| it }
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



79
80
81
# File 'lib/mulang/language.rb', line 79

def name
  @name
end

Instance Method Details

#ast(content, **args) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/mulang/language.rb', line 86

def ast(content, **args)
  if args[:serialization]
    super
  else
    call_tool content
  end
end

#build_analysisObject



101
102
103
# File 'lib/mulang/language.rb', line 101

def build_analysis(*)
  super.deep_merge(spec: {originalLanguage: core_name}.compact)
end

#core_nameObject



105
106
107
# File 'lib/mulang/language.rb', line 105

def core_name
  @name.in?(CORE_LANGUAGES) ? name : nil
end

#sample(content) ⇒ Object



94
95
96
97
98
99
# File 'lib/mulang/language.rb', line 94

def sample(content)
  {
    tag: 'MulangSample',
    ast: call_tool(content)
  }
end