Index: ruby/branches/0.5/lib/adl_parser/lib/parser.rb
===================================================================
--- ruby/branches/0.5/lib/adl_parser/lib/parser.rb	(revision 169)
+++ ruby/branches/0.5/lib/adl_parser/lib/parser.rb	(revision 290)
@@ -11,9 +11,9 @@
 $:.unshift File.join(File.dirname(__FILE__))
 require 'logger'
-#require 'lib/util.rb'
-#require 'lib/scanner.rb'
-require 'lib/adl_parser.rb'
+require 'yaml'
 require 'rubygems'
+require 'adl_parser.rb'
 require 'am.rb'
+require 'rm.rb'
 $DEBUG = false
 
@@ -24,5 +24,5 @@
     class Parser < Racc::Parser
 
-module_eval(<<'...end parser.y/module_eval...', 'parser.y', 1183)
+module_eval(<<'...end parser.y/module_eval...', 'parser.y', 1208)
 
 def assert_at(file,line, message = "")
@@ -33,13 +33,11 @@
 
 if $DEBUG
-  @@log = Logger.new('log/parser.log','daily')
-  @@log.level = Logger::INFO
+  @@logger = Logger.new('log/parser.log','daily')
+  @@logger.level = Logger::DEBUG
 else
-  @@log = Logger.new(STDOUT)
-  @@log.level = Logger::WARN
+  @@logger = Logger.new(STDOUT)
+  @@logger.level = Logger::WARN
 end
 
-@@dadl_scanner = OpenEHR::ADL::Scanner::DADL::RootScanner.new
-@@cadl_scanner = OpenEHR::ADL::Scanner::CADL::RootScanner.new
 
 ###----------/* keywords */ --------------------------------------------- 
@@ -101,25 +99,12 @@
 ###----------/* Scanner */ ----------------------------------------------- 
 
+
 def scan
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan at #{@filename}:#{@lineno}:")
+  scanner = OpenEHR::ADL::Scanner::ADLScanner.new(@adl_type, @filename)
+
   until @data.nil?  do
-    case @adl_type.last
-    when :adl
-      @data = scan_adl(@data) do |sym, val|
+    @data = scanner.scan(@data) do |sym, val|
         yield sym, val
-      end
-    when :dadl
-      @data = scan_dadl(@data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-      @data = scan_cadl(@data) do |sym, val|
-        yield sym, val
-      end
-    when :regexp
-      @data = scan_regexp(@data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
     end
     @data = $' # variable $' receives the string after the match
@@ -128,664 +113,4 @@
   yield false, '$'
 end # of scan
-
-def scan_adl(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :adl
-#      puts "Entering scan_adl"
-      case data
-      when /\A\n/ # carriage return
-        @lineno += 1
-        ;
-      when /\A[ \t\r\f]+/ #just drop it
-        ;
-      when /\A--.*\n/ # single line comment
-        @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
-        ;
-      when /\Adescription/   # description
-        yield :SYM_DESCRIPTION, :SYM_DESCRIPTION
-      when /\Adefinition/   # definition
-        yield :SYM_DEFINITION, :SYM_DEFINITION
-#        @adl_type.push(:cadl)
-        ###----------/* symbols */ ------------------------------------------------- 
-      when /\A[A-Z][a-zA-Z0-9_]*/
-        yield :V_TYPE_IDENTIFIER, $&
-      when /\A[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z0-9]+/   #V_ARCHETYPE_ID
-        yield :V_ARCHETYPE_ID, $&
-      when /\A[a-z][a-zA-Z0-9_]*/
-#        word = $&.downcase
-        word = $&
-        if @@adl_reserved[word]
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: @@adl_reserved = #{@@adl_reserved[word]} at #{@filename}:#{@lineno}")
-          yield @@adl_reserved[word], @@adl_reserved[word]
-        elsif #/\A[A-Z][a-zA-Z0-9_]*/
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: V_ATTRIBUTE_IDENTIFIER = #{$&} at #{@filename}:#{@lineno}")
-          yield :V_ATTRIBUTE_IDENTIFIER, $&
-        end
-      when /\A\=/   # =
-        yield :SYM_EQ, :SYM_EQ
-      when /\A\>=/   # >=
-        yield :SYM_GE, :SYM_GE
-      when /\A\<=/   # <=
-        yield :SYM_LE, :SYM_LE
-      when /\A\</   # <
-        if @in_interval
-#          @start_block_received = false
-          yield :SYM_LT, :SYM_LT
-        else
-#          @start_block_received = true
-          @adl_type.push(:dadl)
-          yield :SYM_START_DBLOCK,  $&
-        end
-      when /\A\>/   # >
-        if @in_interval
-          yield :SYM_GT, :SYM_GT
-        else
-          adl_type = @adl_type.pop
-#          puts "Escaping #{adl_type}"
-          assert_at(__FILE__,__LINE__){adl_type == :dadl}
-          yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
-        end
-      when /\A\{/   # {
-        @adl_type.push(:cadl)
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
-        yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
-      when /\A\}/   # }
-        adl_type = @adl_type.pop
-#        puts "Escaping #{adl_type}"
-        assert_at(__FILE__,__LINE__){adl_type == :cadl}
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
-        yield :SYM_END_CBLOCK, $&
-      when /\A\-/   # -
-        yield :Minus_code, :Minus_code
-      when /\A\+/   # +
-        yield :Plus_code, :Plus_code
-      when /\A\*/   # *
-        yield :Star_code, :Star_code
-      when /\A\//   # /
-        yield :Slash_code, :Slash_code
-      when /\A\^/   # ^
-        yield :Caret_code, :Caret_code
-      when /\A\=/   # =
-        yield :Equal_code, :Equal_code
-      when /\A\.\.\./   # ...
-        yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
-      when /\A\.\./   # ..
-        yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
-      when /\A\./   # .
-        yield :Dot_code, :Dot_code
-      when /\A\;/   # ;
-        yield :Semicolon_code, :Semicolon_code
-      when /\A\,/   # ,
-        yield :Comma_code, :Comma_code
-      when /\A\:/   # :
-        yield :Colon_code, :Colon_code
-      when /\A\!/   # !
-        yield :Exclamation_code, :Exclamation_code
-      when /\A\(/   # (
-        yield :Left_parenthesis_code, :Left_parenthesis_code
-      when /\A\)/   # )
-        yield :Right_parenthesis_code, :Right_parenthesis_code
-      when /\A\$/   # $
-        yield :Dollar_code, :Dollar_code
-      when /\A\?\?/   # ??
-        yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
-      when /\A\?/   # ?
-        yield :Question_mark_code, :Question_mark_code
-      when /\A[0-9]+\.[0-9]+(\.[0-9]+)*/   # ?
-        yield :V_VERSION_STRING, :V_VERSION_STRING
-      when /\A\|/   # |
-        if @in_interval
-          @in_interval = false
-        else
-          @in_interval = true
-        end
-        yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
-      when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/
-#      when /\A\[[a-zA-Z0-9()\._-]+\:\:[a-zA-Z0-9\._-]+\]/   #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
-        yield :V_QUALIFIED_TERM_CODE_REF, $&
-      when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/   #V_LOCAL_TERM_CODE_REF
-        yield :V_LOCAL_TERM_CODE_REF, $&
-      when /\A\[/   # [
-        yield :Left_bracket_code, :Left_bracket_code
-      when /\A\]/   # ]
-        yield :Right_bracket_code, :Right_bracket_code
-
-      when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/   #ERR_V_QUALIFIED_TERM_CODE_REF
-        yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
-      when /\Aa[ct][0-9.]+/   #V_LOCAL_CODE
-        yield :V_LOCAL_CODE, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/   #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
-        yield :V_ISO8601_EXTENDED_DATE_TIME, $&
-      when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? /   #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
-        yield :V_ISO8601_EXTENDED_TIME, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/   #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
-        yield :V_ISO8601_EXTENDED_DATE, $&
-      when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/   #V_GENERIC_TYPE_IDENTIFIER
-        yield :V_GENERIC_TYPE_IDENTIFIER, $&
-      when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/   #V_INTEGER
-        yield :V_INTEGER, $&
-      when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ /   #V_REAL
-        yield :V_REAL, $&
-        #    when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
-      when /\A"([^"]*)"/m #V_STRING
-        yield :V_STRING, $1
-      when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
-        yield :V_URI, $&
-      when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/   #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
-        yield :V_ISO8601_DURATION, $&
-      when /\A\S/ #UTF8CHAR
-        yield :UTF8CHAR, $&
-      end
-      data = $' # variable $' receives the string after the match
-    when :dadl
-#      puts "Entering scan_dadl"
-      data = scan_dadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-#      puts "Entering scan_cadl"
-      data = scan_cadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :regexp
-#      puts "Entering scan_regexp"
-      data = scan_regexp(data) do |sym, val|
-        yield sym, val
-      end
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      data = scan_term_constraint(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end
-end # scan_adl
-
-
-def scan_cadl(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :cadl
-#      puts "Entering scan_cadl"
-      case scanned = @@cadl_scanner.parse(data)
-      when Yaparc::Result::OK
-        if scanned.value[0] == :START_V_C_DOMAIN_TYPE_BLOCK
-          @in_c_domain_type = true
-          @adl_type.push(:dadl)
-          yield scanned.value
-        else
-          yield scanned.value
-        end
-        data = scanned.input
-      end
-
-      case data
-      when /\A\n/ # carriage return
-        @lineno += 1
-        ;
-      when /\A[ \t\r\f]+/ #just drop it
-        ;
-      when /\A--.*\n/ # single line comment
-        @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
-        ;
-        ###----------/* symbols */ ------------------------------------------------- 
-      when /\A\=/   # =
-        yield :SYM_EQ, :SYM_EQ
-      when /\A\>=/   # >=
-        yield :SYM_GE, :SYM_GE
-      when /\A\<=/   # <=
-        yield :SYM_LE, :SYM_LE
-###       when /\A[A-Z][a-zA-Z0-9_]*[ \n]*\</   # V_C_DOMAIN_TYPE
-###         @in_c_domain_type = true
-###         @adl_type.push(:dadl)
-###         yield :START_V_C_DOMAIN_TYPE_BLOCK, $&
-      when /\A\</   # <
-        if @in_interval
-          yield :SYM_LT, :SYM_LT
-        else
-          @adl_type.push(:dadl)
-          yield :SYM_START_DBLOCK,  $&
-        end
-      when /\A\>/   # >
-        if @in_interval
-          yield :SYM_GT, :SYM_GT
-        else
-          adl_type = @adl_type.pop
-#          puts "Escaping #{adl_type}"
-          assert_at(__FILE__,__LINE__){adl_type == :dadl}
-          yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
-        end
-      when /\A\-/   # -
-        yield :Minus_code, :Minus_code
-      when /\A\+/   # +
-        yield :Plus_code, :Plus_code
-      when /\A\*/   # *
-        yield :Star_code, :Star_code
-      when /\A\//   # /
-        yield :Slash_code, :Slash_code
-      when /\A\^/   # ^
-        yield :Caret_code, :Caret_code
-      when /\A\.\.\./   # ...
-        yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
-      when /\A\.\./   # ..
-        yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
-      when /\A\./   # .
-        yield :Dot_code, :Dot_code
-      when /\A\;/   # ;
-        yield :Semicolon_code, :Semicolon_code
-      when /\A\,/   # ,
-        yield :Comma_code, :Comma_code
-      when /\A\:/   # :
-        yield :Colon_code, :Colon_code
-      when /\A\!/   # !
-        yield :Exclamation_code, :Exclamation_code
-      when /\A\(/   # (
-        yield :Left_parenthesis_code, :Left_parenthesis_code
-      when /\A\)/   # )
-        yield :Right_parenthesis_code, :Right_parenthesis_code
-      when /\A\{\// #V_REGEXP
-        if @adl_type.last != :regexp
-          @in_regexp = true
-          @adl_type.push(:regexp)
-          yield :START_REGEXP_BLOCK, :START_REGEXP_BLOCK
-        else
-          raise
-        end
-#        yield :V_REGEXP, :V_REGEXP
-      when /\A\{/   # {
-        @adl_type.push(:cadl)
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
-        yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
-      when /\A\}/   # }
-        adl_type = @adl_type.pop
-#        puts "Escaping #{adl_type}"
-        assert_at(__FILE__,__LINE__){adl_type == :cadl}
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
-        yield :SYM_END_CBLOCK, :SYM_END_CBLOCK
-      when /\A\$/   # $
-        yield :Dollar_code, :Dollar_code
-      when /\A\?\?/   # ??
-        yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
-      when /\A\?/   # ?
-        yield :Question_mark_code, :Question_mark_code
-      when /\A\|/   # |
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
-        if @in_interval
-          @in_interval = false
-        else
-#          @in_interval = false
-          @in_interval = true
-        end
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
-        yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
-
-      when /\A\[[a-zA-Z0-9._\-]+::[a-zA-Z0-9._\-]+\]/   #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
-        yield :V_QUALIFIED_TERM_CODE_REF, $&
-      when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/   #ERR_V_QUALIFIED_TERM_CODE_REF
-        yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
-      when /\A\[([a-zA-Z0-9()._\-]+::[a-zA-Z0-9._\_-]+)\]/
-        yield :V_TERM_CODE_CONSTRAINT, :V_TERM_CODE_CONSTRAINT
-      when /\A\[[a-zA-Z0-9\(\)\._\-]+::[ \t\n]*/
-        @adl_type.push(:term_constraint)
-        yield :START_TERM_CODE_CONSTRAINT, $&
-      when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/   #V_LOCAL_TERM_CODE_REF
-        yield :V_LOCAL_TERM_CODE_REF, $&
-      when /\A\[/   # [
-        yield :Left_bracket_code, :Left_bracket_code
-      when /\A\]/   # ]
-        yield :Right_bracket_code, :Right_bracket_code
-      when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/   #V_GENERIC_TYPE_IDENTIFIER
-        yield :V_GENERIC_TYPE_IDENTIFIER, $&
-      when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X][T\t][hH?X][hH?X]:[mM?X][mM?X]:[sS?X][sS?X]/
-        yield :V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN, $&
-      when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X]/
-        yield :V_ISO8601_DATE_CONSTRAINT_PATTERN, $&
-      when /\A[hH][hH]:[mM?X][mM?X]:[sS?X][sS?X]/
-        yield :V_ISO8601_TIME_CONSTRAINT_PATTERN, $&
-      when /\A[a-z][a-zA-Z0-9_]*/
-        word = $&.dup
-        if @@cadl_reserved[word.downcase]
-          yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]
-        else
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}:#{@lineno}")
-          yield :V_ATTRIBUTE_IDENTIFIER, word #V_ATTRIBUTE_IDENTIFIER /\A[a-z][a-zA-Z0-9_]*/
-        end
-      when /\A[A-Z][a-zA-Z0-9_]*/
-        word = $&.dup
-        if @@cadl_reserved[word.downcase]
-          yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]
-        else
-          yield :V_TYPE_IDENTIFIER, $&
-        end
-      when /\Aa[ct][0-9.]+/   #V_LOCAL_CODE
-        yield :V_LOCAL_CODE, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/   #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
-        yield :V_ISO8601_EXTENDED_DATE_TIME, $&
-      when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? /   #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
-        yield :V_ISO8601_EXTENDED_TIME, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/   #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
-        yield :V_ISO8601_EXTENDED_DATE, $&
-      when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/   #V_INTEGER
-        yield :V_INTEGER, $&
-      when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ /   #V_REAL
-        yield :V_REAL, $&
-           when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
-      when /\A"([^"]*)"/m #V_STRING
-        yield :V_STRING, $1
-      when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
-        yield :V_URI, $&
-###       when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/   #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
-###         yield :V_ISO8601_DURATION, $&
-      when /\A\S/ #UTF8CHAR
-        yield :UTF8CHAR, $&
-      else
-        raise
-      end
-      data = $' # variable $' receives the string after the match
-    when :adl
-#      puts "Entering scan_adl"
-      data = scan_adl(data) do |sym, val|
-        yield sym, val
-      end
-    when :dadl
-#      puts "Entering scan_dadl"
-      data = scan_dadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :regexp
-#      puts "Entering scan_regexp"
-      data = scan_regexp(data) do |sym, val|
-        yield sym, val
-      end
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      data = scan_term_constraint(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end # of until
-end # of scan_cadl
-
-def scan_dadl(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :dadl
-#      puts "Entering scan_dadl"
-      case scanned = @@dadl_scanner.parse(data)
-      when Yaparc::Result::OK
-        yield scanned.value
-        data = scanned.input
-      else
-      end
-
-      case data
-      when /\A\n/ # carriage return
-        @lineno += 1
-        ;
-      when /\A[ \t\r\f]+/ #just drop it
-        ;
-      when /\A--.*\n/ # single line comment
-        @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
-        ;
-        ###----------/* symbols */ ------------------------------------------------- 
-      when /\A\=/   # =
-        yield :SYM_EQ, :SYM_EQ
-      when /\A\>\=/   # >=
-        yield :SYM_GE, :SYM_GE
-      when /\A\<\=/   # <=
-        yield :SYM_LE, :SYM_LE
-      when /\A\</   # <
-        if @in_interval
-          yield :SYM_LT, :SYM_LT
-        else
-          @adl_type.push(:dadl)
-          yield :SYM_START_DBLOCK, :SYM_START_DBLOCK
-        end
-      when /\A\>/   # >
-        if @in_interval
-#          @in_interval = false
-          yield :SYM_GT, :SYM_GT
-        elsif @in_c_domain_type == true
-          assert_at(__FILE__,__LINE__){@adl_type.last == :dadl}
-          adl_type = @adl_type.pop
-          if @adl_type.last == :cadl
-            @in_c_domain_type = false
-            yield :END_V_C_DOMAIN_TYPE_BLOCK, $&
-          else
-            yield :SYM_END_DBLOCK, $&
-          end
-        elsif @in_c_domain_type == false
-          adl_type = @adl_type.pop
-#          puts "Escaping #{adl_type}"
-          assert_at(__FILE__,__LINE__){adl_type == :dadl}
-          yield :SYM_END_DBLOCK, $&
-        else
-          raise
-        end
-      when /\A\-/   # -
-        yield :Minus_code, :Minus_code
-      when /\A\+/   # +
-        yield :Plus_code, :Plus_code
-      when /\A\*/   # *
-        yield :Star_code, :Star_code
-      when /\A\//   # /
-        yield :Slash_code, :Slash_code
-      when /\A\^/   # ^
-        yield :Caret_code, :Caret_code
-      when /\A\.\.\./   # ...
-        yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
-      when /\A\.\./   # ..
-        yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
-      when /\A\./   # .
-        yield :Dot_code, :Dot_code
-      when /\A\;/   # ;
-        yield :Semicolon_code, :Semicolon_code
-      when /\A\,/   # ,
-        yield :Comma_code, :Comma_code
-      when /\A\:/   # :
-        yield :Colon_code, :Colon_code
-      when /\A\!/   # !
-        yield :Exclamation_code, :Exclamation_code
-      when /\A\(/   # (
-        yield :Left_parenthesis_code, :Left_parenthesis_code
-      when /\A\)/   # )
-        yield :Right_parenthesis_code, :Right_parenthesis_code
-      when /\A\$/   # $
-        yield :Dollar_code, :Dollar_code
-      when /\A\?\?/   # ??
-        yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
-      when /\A\?/   # ?
-        yield :Question_mark_code, :Question_mark_code
-      when /\A\|/   # |
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
-        if @in_interval
-          @in_interval = false
-        else
-#          @in_interval = false
-          @in_interval = true
-        end
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
-        yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
-###       when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/   #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
-###         yield :V_QUALIFIED_TERM_CODE_REF, $&
-###       when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/   #V_LOCAL_TERM_CODE_REF
-###         yield :V_LOCAL_TERM_CODE_REF, $&
-###       when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/   #ERR_V_QUALIFIED_TERM_CODE_REF
-###         yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
-      when /\A\[/   # [
-        yield :Left_bracket_code, :Left_bracket_code
-      when /\A\]/   # ]
-        yield :Right_bracket_code, :Right_bracket_code
-###       when /\A[A-Z][a-zA-Z0-9_-]*/
-###         yield :V_TYPE_IDENTIFIER, $&
-###       when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/   #V_GENERIC_TYPE_IDENTIFIER
-###         yield :V_GENERIC_TYPE_IDENTIFIER, $&
-###       when /\A[a-z][a-zA-Z0-9_]*/
-###         word = $&.downcase
-###         if @@dadl_reserved[word]
-###           yield @@dadl_reserved[word], @@dadl_reserved[word]
-###         else
-###           yield :V_ATTRIBUTE_IDENTIFIER, $&
-###         end
-###       when /\Aa[ct][0-9.]+/   #V_LOCAL_CODE
-###         yield :V_LOCAL_CODE, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/   #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
-        yield :V_ISO8601_EXTENDED_DATE_TIME, $&
-      when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? /   #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
-        yield :V_ISO8601_EXTENDED_TIME, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/   #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
-        yield :V_ISO8601_EXTENDED_DATE, $&
-      when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/   #V_GENERIC_TYPE_IDENTIFIER
-        yield :V_GENERIC_TYPE_IDENTIFIER, $&
-      when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/   #V_INTEGER
-        yield :V_INTEGER, $&
-###       when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ /   #V_REAL
-###         yield :V_REAL, $&
-        #    when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
-###       when /\A"([^"]*)"/m #V_STRING
-###         yield :V_STRING, $1
-      when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
-        yield :V_URI, $&
-###       when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/   #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
-###         yield :V_ISO8601_DURATION, $&
-      when /\A\S/ #UTF8CHAR
-        yield :UTF8CHAR, $&
-      end
-      data = $' # variable $' receives the string after the match
-    when :adl
-#      puts "Entering scan_adl"
-      data = scan_adl(data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-#      puts "Entering scan_cadl"
-      data = scan_cadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :regexp
-#      puts "Entering scan_regexp"
-      data = scan_regexp(data) do |sym, val|
-        yield sym, val
-      end
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      data = scan_term_constraint(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end
-end # of scan_dadl
-
-def scan_regexp(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :regexp
-#      puts "Entering scan_regexp"
-      case data
-      when /\A\/\}/ #V_REGEXP
-        if @adl_type.last == :regexp
-          @in_regexp = false
-          @adl_type.pop
-          yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK
-        else
-          raise
-        end
-      when /\A(.*)(\/\})/ #V_REGEXP
-        yield :REGEXP_BODY, $1
-        if @adl_type.last == :regexp
-          @in_regexp = false
-          @adl_type.pop
-          yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK
-        else
-          raise
-        end
-      else
-        raise data
-      end
-      data = $' # variable $' receives the string after the match
-    when :adl
-#      puts "Entering scan_adl"
-      data = scan_adl(data) do |sym, val|
-        yield sym, val
-      end
-    when :dadl
-#      puts "Entering scan_dadl"
-      data = scan_dadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-#      puts "Entering scan_cadl"
-      data = scan_cadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      data = scan_term_constraint(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end
-end # of scan_regexp
-
-def scan_term_constraint(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      case data
-      when /\A\n/ # carriage return
-        @lineno += 1
-        ;
-      when /\A[ \t\r\f]+/ #just drop it
-        ;
-      when /\A--.*$/ # single line comment
-        @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_term_constraint: COMMENT = #{$&} at #{@filename}:#{@lineno}")
-        ;
-      when /\A[a-zA-Z0-9\._\-]+[ \t]*,/ # match any line, with ',' termination
-        yield :TERM_CODE, $&
-      when /\A[a-zA-Z0-9\._\-]+[ \t]*;/ #match second last line with ';' termination (assumed value)
-        yield :TERM_CODE, $&
-#      when /\A[a-zA-Z0-9\._\-]+[ \t]*\]/ # match final line, terminating in ']'
-      when /\A[a-zA-Z0-9\._\-]*[ \t]*\]/ # match final line, terminating in ']'
-        adl_type = @adl_type.pop
-        assert_at(__FILE__,__LINE__){adl_type == :term_constraint}
-        yield :END_TERM_CODE_CONSTRAINT, $&
-      else
-        raise "data = #{data}"
-      end
-      data = $' # variable $' receives the string after the match
-    when :adl
-#      puts "Entering scan_adl"
-      data = scan_adl(data) do |sym, val|
-        yield sym, val
-      end
-    when :dadl
-#      puts "Entering scan_dadl"
-      data = scan_dadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-#      puts "Entering scan_cadl"
-      data = scan_cadl(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end
-end # of scan_term_constraint
 
 
@@ -808,5 +133,5 @@
 
 
-
+__END__
 
 
@@ -1128,6 +453,6 @@
   -376,  -376,  -376,  -195,  -376,  -208,  -376,  -221,  -376,  -234,
   -376,  -376,  -376,   -43,  -305,  -376,   -53,   -44,  -376,  -376,
-   -31,   -72,  -310,   -70,   -35,   -37,  -372,   -38,   -39,  -360,
-   -40,  -376,  -363,   -41,  -367,  -366,   -42,  -369,  -376,   -36,
+   -31,   -72,  -310,   -70,   -36,   -37,  -372,   -38,   -39,  -360,
+   -40,  -376,  -363,   -41,  -367,  -366,   -42,  -369,  -376,   -35,
   -376,  -376,  -376,  -376,  -376,  -309,  -160,  -175,  -159,  -376,
   -174,  -376,  -196,  -376,  -209,  -376,  -222,  -376,  -235,  -376,
@@ -1306,5 +631,5 @@
   1, 109, :_reduce_12,
   0, 99, :_reduce_none,
-  2, 99, :_reduce_none,
+  2, 99, :_reduce_14,
   2, 99, :_reduce_none,
   2, 100, :_reduce_16,
@@ -1337,13 +662,13 @@
   1, 121, :_reduce_none,
   1, 121, :_reduce_none,
-  3, 122, :_reduce_45,
-  4, 123, :_reduce_46,
-  3, 123, :_reduce_none,
-  6, 124, :_reduce_48,
+  3, 128, :_reduce_45,
+  4, 122, :_reduce_46,
+  3, 122, :_reduce_none,
+  6, 123, :_reduce_48,
   2, 130, :_reduce_49,
   2, 133, :_reduce_50,
   3, 133, :_reduce_none,
   2, 133, :_reduce_none,
-  1, 128, :_reduce_53,
+  1, 127, :_reduce_53,
   1, 134, :_reduce_54,
   1, 134, :_reduce_55,
@@ -1483,5 +808,5 @@
   3, 189, :_reduce_none,
   3, 189, :_reduce_none,
-  1, 180, :_reduce_none,
+  1, 180, :_reduce_191,
   3, 190, :_reduce_none,
   3, 190, :_reduce_none,
@@ -1652,17 +977,17 @@
   3, 142, :_reduce_358,
   3, 142, :_reduce_359,
-  1, 127, :_reduce_none,
-  3, 127, :_reduce_none,
-  3, 127, :_reduce_none,
+  1, 126, :_reduce_none,
+  3, 126, :_reduce_none,
+  3, 126, :_reduce_none,
   1, 221, :_reduce_none,
   3, 221, :_reduce_none,
   3, 222, :_reduce_365,
-  1, 126, :_reduce_366,
-  1, 126, :_reduce_367,
-  3, 223, :_reduce_none,
+  1, 125, :_reduce_366,
+  1, 125, :_reduce_367,
+  3, 223, :_reduce_368,
   0, 224, :_reduce_none,
   1, 224, :_reduce_none,
   2, 224, :_reduce_none,
-  1, 125, :_reduce_372,
+  1, 124, :_reduce_372,
   1, 150, :_reduce_373,
   1, 150, :_reduce_374,
@@ -1913,5 +1238,4 @@
   "c_attributes",
   "c_object",
-  "v_c_domain_type",
   "archetype_internal_ref",
   "archetype_slot",
@@ -1920,4 +1244,5 @@
   "c_ordinal",
   "c_primitive_object",
+  "v_c_domain_type",
   "absolute_path",
   "c_archetype_slot_head",
@@ -2040,4 +1365,5 @@
     
     archetype_id = val[0][:archetype_id]
+    parent_archtype_id = val[1][:parent_archtype_id] if val[1]
     adl_version = val[0][:arch_head][:arch_meta_data][:adl_version]
     concept = val[2]
@@ -2045,4 +1371,5 @@
     archetype = OpenEHR::AM::Archetype::ARCHETYPE.create(
                                                          :archetype_id => archetype_id,
+                                                         :parent_archtype_id => parent_archtype_id,
                                                          :adl_version => adl_version,
                                                          :concept => concept,
@@ -2053,5 +1380,5 @@
       archetype.original_language = language
     end
-    @@log.info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: archetype = #{archetype.to_yaml} at #{@filename}:#{@lineno}")
     result = archetype
   
@@ -2060,5 +1387,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 61)
+module_eval(<<'.,.,', 'parser.y', 63)
   def _reduce_4(val, _values, result)
         result = {:arch_head => val[0], :archetype_id => val[1] }
@@ -2068,5 +1395,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 65)
+module_eval(<<'.,.,', 'parser.y', 67)
   def _reduce_5(val, _values, result)
         raise
@@ -2076,5 +1403,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 70)
+module_eval(<<'.,.,', 'parser.y', 72)
   def _reduce_6(val, _values, result)
         result = {:arch_meta_data => nil }
@@ -2084,5 +1411,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 74)
+module_eval(<<'.,.,', 'parser.y', 76)
   def _reduce_7(val, _values, result)
         result = val[1]
@@ -2092,5 +1419,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 79)
+module_eval(<<'.,.,', 'parser.y', 81)
   def _reduce_8(val, _values, result)
         result = {:arch_meta_data => val[1] }
@@ -2100,5 +1427,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 84)
+module_eval(<<'.,.,', 'parser.y', 86)
   def _reduce_9(val, _values, result)
         result = val[0]
@@ -2108,5 +1435,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 88)
+module_eval(<<'.,.,', 'parser.y', 90)
   def _reduce_10(val, _values, result)
         result = val[0].merge(val[2])
@@ -2116,5 +1443,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 94)
+module_eval(<<'.,.,', 'parser.y', 96)
   def _reduce_11(val, _values, result)
         result = {:adl_version => val[2], :is_controlled => false }
@@ -2124,5 +1451,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 98)
+module_eval(<<'.,.,', 'parser.y', 100)
   def _reduce_12(val, _values, result)
         result = {:is_controlled => true }
@@ -2134,9 +1461,15 @@
 # reduce 13 omitted
 
-# reduce 14 omitted
+module_eval(<<'.,.,', 'parser.y', 108)
+  def _reduce_14(val, _values, result)
+        result = {:parent_archtype_id => val[1]}
+  
+    result
+  end
+.,.,
 
 # reduce 15 omitted
 
-module_eval(<<'.,.,', 'parser.y', 109)
+module_eval(<<'.,.,', 'parser.y', 114)
   def _reduce_16(val, _values, result)
         result = {:arch_concept => val[1] }
@@ -2148,5 +1481,5 @@
 # reduce 17 omitted
 
-module_eval(<<'.,.,', 'parser.y', 119)
+module_eval(<<'.,.,', 'parser.y', 124)
   def _reduce_18(val, _values, result)
         result = {:arch_language => nil}
@@ -2156,5 +1489,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 123)
+module_eval(<<'.,.,', 'parser.y', 128)
   def _reduce_19(val, _values, result)
         result = {:arch_language => val[1]}
@@ -2168,5 +1501,5 @@
 # reduce 21 omitted
 
-module_eval(<<'.,.,', 'parser.y', 134)
+module_eval(<<'.,.,', 'parser.y', 139)
   def _reduce_22(val, _values, result)
         result = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new(:details => val[1])
@@ -2178,5 +1511,5 @@
 # reduce 23 omitted
 
-module_eval(<<'.,.,', 'parser.y', 142)
+module_eval(<<'.,.,', 'parser.y', 147)
   def _reduce_24(val, _values, result)
         result = val[1]
@@ -2188,8 +1521,8 @@
 # reduce 25 omitted
 
-module_eval(<<'.,.,', 'parser.y', 150)
+module_eval(<<'.,.,', 'parser.y', 155)
   def _reduce_26(val, _values, result)
         assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT)}
-    @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2198,5 +1531,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 156)
+module_eval(<<'.,.,', 'parser.y', 161)
   def _reduce_27(val, _values, result)
         result = val[0]
@@ -2206,5 +1539,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 163)
+module_eval(<<'.,.,', 'parser.y', 168)
   def _reduce_28(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
@@ -2218,5 +1551,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 171)
+module_eval(<<'.,.,', 'parser.y', 176)
   def _reduce_29(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
@@ -2230,5 +1563,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 182)
+module_eval(<<'.,.,', 'parser.y', 187)
   def _reduce_30(val, _values, result)
         result = {:c_complex_object_id => val[0], :c_occurrences => val[1]}
@@ -2238,5 +1571,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 187)
+module_eval(<<'.,.,', 'parser.y', 192)
   def _reduce_31(val, _values, result)
         result = {:type_identifier => val[0]}
@@ -2246,5 +1579,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 191)
+module_eval(<<'.,.,', 'parser.y', 196)
   def _reduce_32(val, _values, result)
         result = {:type_identifier => val[0], :local_term_code_ref => val[1]}
@@ -2256,5 +1589,5 @@
 # reduce 33 omitted
 
-module_eval(<<'.,.,', 'parser.y', 197)
+module_eval(<<'.,.,', 'parser.y', 202)
   def _reduce_34(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => val[0])
@@ -2264,23 +1597,15 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 205)
+module_eval(<<'.,.,', 'parser.y', 220)
   def _reduce_35(val, _values, result)
-        result = val[0]
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 209)
+        @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")
+    result = val[0]
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 225)
   def _reduce_36(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")
-    result = val[0]
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 214)
-  def _reduce_37(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.create do |archetype_internal_ref|
       archetype_internal_ref.target_path = val[0][:absolute_path]
@@ -2293,14 +1618,14 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 222)
+module_eval(<<'.,.,', 'parser.y', 233)
+  def _reduce_37(val, _values, result)
+        result = val[0]
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 237)
   def _reduce_38(val, _values, result)
-        result = val[0]
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 226)
-  def _reduce_39(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.create do |constraint_ref|
       constraint_ref.reference = val[0]
@@ -2311,5 +1636,13 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 232)
+module_eval(<<'.,.,', 'parser.y', 243)
+  def _reduce_39(val, _values, result)
+        result = val[0]
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 247)
   def _reduce_40(val, _values, result)
         result = val[0]
@@ -2319,5 +1652,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 236)
+module_eval(<<'.,.,', 'parser.y', 251)
   def _reduce_41(val, _values, result)
         result = val[0]
@@ -2327,5 +1660,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 240)
+module_eval(<<'.,.,', 'parser.y', 255)
   def _reduce_42(val, _values, result)
         result = val[0]
@@ -2339,5 +1672,5 @@
 # reduce 44 omitted
 
-module_eval(<<'.,.,', 'parser.y', 255)
+module_eval(<<'.,.,', 'parser.y', 271)
   def _reduce_45(val, _values, result)
         result = val[1]
@@ -2347,5 +1680,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 261)
+module_eval(<<'.,.,', 'parser.y', 277)
   def _reduce_46(val, _values, result)
         result = {:type_identifier => val[1], :c_occurrences => val[2], :absolute_path => val[3] }
@@ -2357,5 +1690,5 @@
 # reduce 47 omitted
 
-module_eval(<<'.,.,', 'parser.y', 268)
+module_eval(<<'.,.,', 'parser.y', 284)
   def _reduce_48(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.create do |archetype_slot|
@@ -2370,5 +1703,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 277)
+module_eval(<<'.,.,', 'parser.y', 293)
   def _reduce_49(val, _values, result)
         result = {:c_archetype_slot_id => val[0],:c_occurrences => val[1]}
@@ -2378,5 +1711,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 282)
+module_eval(<<'.,.,', 'parser.y', 298)
   def _reduce_50(val, _values, result)
         result = val[1]
@@ -2390,5 +1723,5 @@
 # reduce 52 omitted
 
-module_eval(<<'.,.,', 'parser.y', 290)
+module_eval(<<'.,.,', 'parser.y', 306)
   def _reduce_53(val, _values, result)
         assert_at(__FILE__,__LINE__){val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE)}
@@ -2401,7 +1734,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 298)
+module_eval(<<'.,.,', 'parser.y', 314)
   def _reduce_54(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.create do |c_integer|
       c_integer.list
@@ -2414,7 +1747,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 307)
+module_eval(<<'.,.,', 'parser.y', 323)
   def _reduce_55(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new
   
@@ -2423,7 +1756,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 312)
+module_eval(<<'.,.,', 'parser.y', 328)
   def _reduce_56(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new
   
@@ -2432,7 +1765,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 317)
+module_eval(<<'.,.,', 'parser.y', 333)
   def _reduce_57(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new
   
@@ -2441,7 +1774,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 322)
+module_eval(<<'.,.,', 'parser.y', 338)
   def _reduce_58(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new
   
@@ -2450,7 +1783,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 327)
+module_eval(<<'.,.,', 'parser.y', 343)
   def _reduce_59(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new
   
@@ -2459,7 +1792,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 332)
+module_eval(<<'.,.,', 'parser.y', 348)
   def _reduce_60(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new
   
@@ -2468,8 +1801,8 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 337)
+module_eval(<<'.,.,', 'parser.y', 353)
   def _reduce_61(val, _values, result)
         assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN)}
-    @@log.info("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2480,5 +1813,5 @@
 # reduce 62 omitted
 
-module_eval(<<'.,.,', 'parser.y', 349)
+module_eval(<<'.,.,', 'parser.y', 365)
   def _reduce_63(val, _values, result)
         result = [val[0]]
@@ -2488,5 +1821,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 353)
+module_eval(<<'.,.,', 'parser.y', 369)
   def _reduce_64(val, _values, result)
         result = (val[0] << val[1])
@@ -2496,5 +1829,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 359)
+module_eval(<<'.,.,', 'parser.y', 375)
   def _reduce_65(val, _values, result)
         assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
@@ -2507,5 +1840,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 366)
+module_eval(<<'.,.,', 'parser.y', 382)
   def _reduce_66(val, _values, result)
         assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
@@ -2516,5 +1849,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 371)
+module_eval(<<'.,.,', 'parser.y', 387)
   def _reduce_67(val, _values, result)
         assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
@@ -2525,7 +1858,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 378)
+module_eval(<<'.,.,', 'parser.y', 394)
   def _reduce_68(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}")
     result = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new(
                                                                               :rm_attribute_name => val[0],
@@ -2538,8 +1871,8 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 387)
+module_eval(<<'.,.,', 'parser.y', 403)
   def _reduce_69(val, _values, result)
         assert_at(__FILE__,__LINE__){ val[2].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY) }
-    @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}") 
     result = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new(
                                                                                 :rm_attribute_name => val[0],
@@ -2552,5 +1885,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 398)
+module_eval(<<'.,.,', 'parser.y', 414)
   def _reduce_70(val, _values, result)
         result = Array[val[0]]
@@ -2560,5 +1893,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 402)
+module_eval(<<'.,.,', 'parser.y', 418)
   def _reduce_71(val, _values, result)
         result = (val[0] << val[1])
@@ -2568,5 +1901,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 406)
+module_eval(<<'.,.,', 'parser.y', 422)
   def _reduce_72(val, _values, result)
         result = Array[val[0]]
@@ -2578,5 +1911,5 @@
 # reduce 73 omitted
 
-module_eval(<<'.,.,', 'parser.y', 414)
+module_eval(<<'.,.,', 'parser.y', 430)
   def _reduce_74(val, _values, result)
         result = val[1]
@@ -2588,5 +1921,5 @@
 # reduce 75 omitted
 
-module_eval(<<'.,.,', 'parser.y', 422)
+module_eval(<<'.,.,', 'parser.y', 438)
   def _reduce_76(val, _values, result)
         result = val[1]
@@ -2612,5 +1945,5 @@
 # reduce 84 omitted
 
-module_eval(<<'.,.,', 'parser.y', 442)
+module_eval(<<'.,.,', 'parser.y', 458)
   def _reduce_85(val, _values, result)
         dadl_section = val[1]
@@ -2629,5 +1962,5 @@
 # reduce 89 omitted
 
-module_eval(<<'.,.,', 'parser.y', 457)
+module_eval(<<'.,.,', 'parser.y', 473)
   def _reduce_90(val, _values, result)
         result = Array[val[0]]
@@ -2637,5 +1970,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 461)
+module_eval(<<'.,.,', 'parser.y', 477)
   def _reduce_91(val, _values, result)
         result = (val[0] << val[1])
@@ -2645,5 +1978,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 465)
+module_eval(<<'.,.,', 'parser.y', 481)
   def _reduce_92(val, _values, result)
         result = (val[0] << val[2])
@@ -2653,7 +1986,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 470)
+module_eval(<<'.,.,', 'parser.y', 486)
   def _reduce_93(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:attr_id => val[0], :object_block => val[2]}
   
@@ -2662,7 +1995,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 476)
+module_eval(<<'.,.,', 'parser.y', 492)
   def _reduce_94(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2673,5 +2006,5 @@
 # reduce 95 omitted
 
-module_eval(<<'.,.,', 'parser.y', 483)
+module_eval(<<'.,.,', 'parser.y', 499)
   def _reduce_96(val, _values, result)
         result = val[0]
@@ -2681,5 +2014,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 487)
+module_eval(<<'.,.,', 'parser.y', 503)
   def _reduce_97(val, _values, result)
         result = val[0]
@@ -2689,5 +2022,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 492)
+module_eval(<<'.,.,', 'parser.y', 508)
   def _reduce_98(val, _values, result)
         result = val[0]
@@ -2697,5 +2030,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 496)
+module_eval(<<'.,.,', 'parser.y', 512)
   def _reduce_99(val, _values, result)
         result = val[0]
@@ -2705,5 +2038,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 501)
+module_eval(<<'.,.,', 'parser.y', 517)
   def _reduce_100(val, _values, result)
         result = {:untyped_multiple_attr_object_block => val[0]}
@@ -2713,5 +2046,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 505)
+module_eval(<<'.,.,', 'parser.y', 521)
   def _reduce_101(val, _values, result)
         result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]}
@@ -2721,5 +2054,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 510)
+module_eval(<<'.,.,', 'parser.y', 526)
   def _reduce_102(val, _values, result)
         result = {:multiple_attr_object_block_head => val[0], :keyed_objects => val[1]}
@@ -2729,14 +2062,13 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 515)
+module_eval(<<'.,.,', 'parser.y', 531)
   def _reduce_103(val, _values, result)
-        @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
-    result = val[0]
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 521)
+        result = val[0]
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 536)
   def _reduce_104(val, _values, result)
         result = Array[val[0]]
@@ -2746,5 +2078,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 525)
+module_eval(<<'.,.,', 'parser.y', 540)
   def _reduce_105(val, _values, result)
         result = (val[0] << val[1])
@@ -2754,16 +2086,16 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 530)
+module_eval(<<'.,.,', 'parser.y', 545)
   def _reduce_106(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
-    result = {:object_key => val[0], :object_block => val[1]}
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 536)
+        @@logger.debug("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]} at #{@filename}:#{@lineno}")
+    result = {:object_key => val[0], :object_block => val[2]}
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 551)
   def _reduce_107(val, _values, result)
-        @@log.info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
+        @@logger.debug("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
     result = val[1]
   
@@ -2772,5 +2104,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 542)
+module_eval(<<'.,.,', 'parser.y', 557)
   def _reduce_108(val, _values, result)
         result = {:untyped_single_attr_object_block => val[0]}
@@ -2780,5 +2112,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 546)
+module_eval(<<'.,.,', 'parser.y', 561)
   def _reduce_109(val, _values, result)
         result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]}
@@ -2788,7 +2120,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 551)
+module_eval(<<'.,.,', 'parser.y', 566)
   def _reduce_110(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:single_attr_object_complex_head => val[0]}
   
@@ -2797,7 +2129,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 556)
+module_eval(<<'.,.,', 'parser.y', 571)
   def _reduce_111(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]}, attr_vals = #{val[1]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: attr_vals = #{val[1]} at #{@filename}:#{@lineno}")
     result = {:single_attr_object_complex_head => val[0], :attr_vals => val[1]}
   
@@ -2808,7 +2140,7 @@
 # reduce 112 omitted
 
-module_eval(<<'.,.,', 'parser.y', 562)
+module_eval(<<'.,.,', 'parser.y', 577)
   def _reduce_113(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:untyped_primitive_object_block => val[0]}
   
@@ -2817,7 +2149,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 567)
+module_eval(<<'.,.,', 'parser.y', 582)
   def _reduce_114(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")
     result = {:type_identifier => val[0], :untyped_primitive_object_block => val[1]}
   
@@ -2826,7 +2158,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 572)
+module_eval(<<'.,.,', 'parser.y', 587)
   def _reduce_115(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}")
     result = val[1]
   
@@ -2835,5 +2167,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 577)
+module_eval(<<'.,.,', 'parser.y', 592)
   def _reduce_116(val, _values, result)
         result = val[0]
@@ -2843,5 +2175,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 581)
+module_eval(<<'.,.,', 'parser.y', 596)
   def _reduce_117(val, _values, result)
         result = val[0]
@@ -2851,5 +2183,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 585)
+module_eval(<<'.,.,', 'parser.y', 600)
   def _reduce_118(val, _values, result)
         result = val[0]
@@ -2859,5 +2191,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 589)
+module_eval(<<'.,.,', 'parser.y', 604)
   def _reduce_119(val, _values, result)
         result = val[0]
@@ -2867,5 +2199,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 593)
+module_eval(<<'.,.,', 'parser.y', 608)
   def _reduce_120(val, _values, result)
         result = val[0]
@@ -2875,7 +2207,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 597)
+module_eval(<<'.,.,', 'parser.y', 612)
   def _reduce_121(val, _values, result)
-        @@log.info("string_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("string_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2884,7 +2216,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 602)
+module_eval(<<'.,.,', 'parser.y', 617)
   def _reduce_122(val, _values, result)
-        @@log.info("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2893,7 +2225,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 607)
+module_eval(<<'.,.,', 'parser.y', 622)
   def _reduce_123(val, _values, result)
-        @@log.info("real_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("real_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2902,7 +2234,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 612)
+module_eval(<<'.,.,', 'parser.y', 627)
   def _reduce_124(val, _values, result)
-        @@log.info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2911,7 +2243,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 617)
+module_eval(<<'.,.,', 'parser.y', 632)
   def _reduce_125(val, _values, result)
-        @@log.info("character_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("character_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2920,7 +2252,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 622)
+module_eval(<<'.,.,', 'parser.y', 637)
   def _reduce_126(val, _values, result)
-        @@log.info("date_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("date_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2929,7 +2261,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 627)
+module_eval(<<'.,.,', 'parser.y', 642)
   def _reduce_127(val, _values, result)
-        @@log.info("time_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("time_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2938,7 +2270,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 632)
+module_eval(<<'.,.,', 'parser.y', 647)
   def _reduce_128(val, _values, result)
-        @@log.info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2947,7 +2279,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 637)
+module_eval(<<'.,.,', 'parser.y', 652)
   def _reduce_129(val, _values, result)
-        @@log.info("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2956,7 +2288,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 642)
+module_eval(<<'.,.,', 'parser.y', 657)
   def _reduce_130(val, _values, result)
-        @@log.info("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2995,7 +2327,7 @@
 # reduce 145 omitted
 
-module_eval(<<'.,.,', 'parser.y', 665)
+module_eval(<<'.,.,', 'parser.y', 680)
   def _reduce_146(val, _values, result)
-        @@log.info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -3004,7 +2336,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 670)
+module_eval(<<'.,.,', 'parser.y', 685)
   def _reduce_147(val, _values, result)
-        @@log.info("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -3013,7 +2345,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 676)
+module_eval(<<'.,.,', 'parser.y', 691)
   def _reduce_148(val, _values, result)
-        @@log.info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -3028,5 +2360,5 @@
 # reduce 151 omitted
 
-module_eval(<<'.,.,', 'parser.y', 686)
+module_eval(<<'.,.,', 'parser.y', 701)
   def _reduce_152(val, _values, result)
         begin
@@ -3041,5 +2373,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 695)
+module_eval(<<'.,.,', 'parser.y', 710)
   def _reduce_153(val, _values, result)
         begin
@@ -3054,5 +2386,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 704)
+module_eval(<<'.,.,', 'parser.y', 719)
   def _reduce_154(val, _values, result)
         begin
@@ -3091,5 +2423,5 @@
 # reduce 166 omitted
 
-module_eval(<<'.,.,', 'parser.y', 730)
+module_eval(<<'.,.,', 'parser.y', 745)
   def _reduce_167(val, _values, result)
         begin
@@ -3104,5 +2436,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 739)
+module_eval(<<'.,.,', 'parser.y', 754)
   def _reduce_168(val, _values, result)
         begin
@@ -3117,5 +2449,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 748)
+module_eval(<<'.,.,', 'parser.y', 763)
   def _reduce_169(val, _values, result)
         begin
@@ -3154,5 +2486,5 @@
 # reduce 181 omitted
 
-module_eval(<<'.,.,', 'parser.y', 773)
+module_eval(<<'.,.,', 'parser.y', 788)
   def _reduce_182(val, _values, result)
         result = true
@@ -3162,5 +2494,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 777)
+module_eval(<<'.,.,', 'parser.y', 792)
   def _reduce_183(val, _values, result)
         result = false
@@ -3184,5 +2516,11 @@
 # reduce 190 omitted
 
-# reduce 191 omitted
+module_eval(<<'.,.,', 'parser.y', 807)
+  def _reduce_191(val, _values, result)
+        result = val[0]
+  
+    result
+  end
+.,.,
 
 # reduce 192 omitted
@@ -3262,7 +2600,7 @@
 # reduce 229 omitted
 
-module_eval(<<'.,.,', 'parser.y', 840)
+module_eval(<<'.,.,', 'parser.y', 858)
   def _reduce_230(val, _values, result)
-        @@log.info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -3295,7 +2633,7 @@
 # reduce 242 omitted
 
-module_eval(<<'.,.,', 'parser.y', 860)
+module_eval(<<'.,.,', 'parser.y', 878)
   def _reduce_243(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -3310,7 +2648,7 @@
 # reduce 246 omitted
 
-module_eval(<<'.,.,', 'parser.y', 870)
+module_eval(<<'.,.,', 'parser.y', 888)
   def _reduce_247(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -3399,21 +2737,21 @@
 # reduce 287 omitted
 
-module_eval(<<'.,.,', 'parser.y', 940)
+module_eval(<<'.,.,', 'parser.y', 958)
   def _reduce_288(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 944)
+        @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 962)
   def _reduce_289(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 955)
+        @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 973)
   def _reduce_290(val, _values, result)
         result = Range.new(1,1)
@@ -3423,5 +2761,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 959)
+module_eval(<<'.,.,', 'parser.y', 977)
   def _reduce_291(val, _values, result)
         result = val[3]
@@ -3431,5 +2769,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 964)
+module_eval(<<'.,.,', 'parser.y', 982)
   def _reduce_292(val, _values, result)
         begin
@@ -3444,5 +2782,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 973)
+module_eval(<<'.,.,', 'parser.y', 991)
   def _reduce_293(val, _values, result)
         begin
@@ -3458,5 +2796,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 984)
+module_eval(<<'.,.,', 'parser.y', 1002)
   def _reduce_294(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new
@@ -3482,5 +2820,5 @@
 # reduce 302 omitted
 
-module_eval(<<'.,.,', 'parser.y', 998)
+module_eval(<<'.,.,', 'parser.y', 1016)
   def _reduce_303(val, _values, result)
         result = val[0]
@@ -3490,5 +2828,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1002)
+module_eval(<<'.,.,', 'parser.y', 1020)
   def _reduce_304(val, _values, result)
         result = val[0]
@@ -3500,5 +2838,5 @@
 # reduce 305 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1009)
+module_eval(<<'.,.,', 'parser.y', 1027)
   def _reduce_306(val, _values, result)
         result = val[3]
@@ -3600,5 +2938,5 @@
 # reduce 352 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1079)
+module_eval(<<'.,.,', 'parser.y', 1097)
   def _reduce_353(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true)
@@ -3608,5 +2946,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1083)
+module_eval(<<'.,.,', 'parser.y', 1101)
   def _reduce_354(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false)
@@ -3616,5 +2954,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1087)
+module_eval(<<'.,.,', 'parser.y', 1105)
   def _reduce_355(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,:false_valid => false)
@@ -3624,5 +2962,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1091)
+module_eval(<<'.,.,', 'parser.y', 1109)
   def _reduce_356(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false,:false_valid => true)
@@ -3632,5 +2970,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1096)
+module_eval(<<'.,.,', 'parser.y', 1114)
   def _reduce_357(val, _values, result)
         result = val[0]
@@ -3640,5 +2978,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1100)
+module_eval(<<'.,.,', 'parser.y', 1118)
   def _reduce_358(val, _values, result)
         raise 'Not implemented yet'
@@ -3648,5 +2986,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1104)
+module_eval(<<'.,.,', 'parser.y', 1122)
   def _reduce_359(val, _values, result)
         raise 'Not implemented yet'
@@ -3666,14 +3004,14 @@
 # reduce 364 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1116)
+module_eval(<<'.,.,', 'parser.y', 1134)
   def _reduce_365(val, _values, result)
         @in_interval = false
-    @@log.info("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 1123)
+    @@logger.debug("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 1141)
   def _reduce_366(val, _values, result)
           result = val[0]
@@ -3683,5 +3021,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1127)
+module_eval(<<'.,.,', 'parser.y', 1145)
   def _reduce_367(val, _values, result)
           result = val[0]
@@ -3691,5 +3029,14 @@
 .,.,
 
-# reduce 368 omitted
+module_eval(<<'.,.,', 'parser.y', 1151)
+  def _reduce_368(val, _values, result)
+        @@logger.debug("#{__FILE__}:#{__LINE__}, START_TERM_CODE_CONSTRAINT = #{val[0]} at #{@filename}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}, term_code_body = #{val[1]}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}, END_TERM_CODE_CONSTRAINT = #{val[2]}")
+    result = val[1]
+  
+    result
+  end
+.,.,
 
 # reduce 369 omitted
@@ -3699,5 +3046,5 @@
 # reduce 371 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1142)
+module_eval(<<'.,.,', 'parser.y', 1167)
   def _reduce_372(val, _values, result)
           result = val[0]
@@ -3707,5 +3054,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1147)
+module_eval(<<'.,.,', 'parser.y', 1172)
   def _reduce_373(val, _values, result)
           result = val[0]
@@ -3715,7 +3062,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1151)
+module_eval(<<'.,.,', 'parser.y', 1176)
   def _reduce_374(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
       result = val[0]
   
@@ -3724,5 +3071,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1162)
+module_eval(<<'.,.,', 'parser.y', 1187)
   def _reduce_375(val, _values, result)
         result = val[0]
