Class: OpenEHR::Parser::ADLParser

Inherits:
Base
  • Object
show all
Defined in:
lib/open_ehr/parser/adl_parser.rb

Instance Attribute Summary

Attributes inherited from Base

#filename

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ ADLParser

Returns a new instance of ADLParser.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/open_ehr/parser/adl_parser.rb', line 14

def initialize(filename)
  super(filename)
  data = File.read(filename)
  Treetop.load(File.dirname(__FILE__)+'/adl_grammar.tt')
  ap = ADLGrammarParser.new
  @result = ap.parse(data)
  if @result.nil?
    puts ap.failure_reason
    puts ap.failure_line
    puts ap.failure_column
  end
end

Instance Method Details

#parseObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/open_ehr/parser/adl_parser.rb', line 27

def parse
  original_language = @result.original_language
  archetype_id = ArchetypeID.new(:value => @result.archetype_id)
  definition = @result.definition
  ontology = @result.ontology
  archetype = Archetype.new(:archetype_id => archetype_id,
                            :adl_version => @result.adl_version,
                            :concept => @result.concept,
                            :original_language => original_language,
                            :translation => @result.translations,
                            :description => @result.description,
                            :definition => @result.definition,
                            :ontology => @result.ontology)
  return archetype
end