Index: /ruby/branches/0.5/lib/adl_parser/Rakefile
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/Rakefile	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/Rakefile	(revision 290)
@@ -1,4 +1,3 @@
 require 'rubygems'
-#Gem::manage_gems
 require 'rake'
 require 'rake/testtask'
@@ -26,6 +25,4 @@
   end
 end
-
-
 
 desc "Generate TAGS by rtags."
@@ -79,5 +76,5 @@
   s.name = 'adl_parser'
   s.author = 'Akimichi Tatsukawa'
-  s.version = '0.0.3'
+  s.version = '0.0.4'
   s.summary = 'ADL parser'
   s.email = 'akimichi.tatsukawa@gmail.com'
@@ -85,5 +82,5 @@
   candidates = Dir.glob("{bin,docs,lib,test,ext}/**/*")
   s.files = candidates.delete_if do |item|
-    item.include?(".svn") || item.include?("rdoc")
+    item.include?(".svn") || item.include?("rdoc") || item.include?("log")
   end
   s.files = FileList['README', 'COPYING', 'Rakefile']
@@ -91,6 +88,6 @@
   s.has_rdoc = true
   s.extra_rdoc_files = ["README"]
-  s.add_dependency("yaparc", ">= 0.2.3")
-  s.add_dependency("openehr_models", ">= 0.0.1")
+#  s.add_dependency("yaparc", ">= 0.2.3")
+  s.add_dependency("openehr_models", ">= 0.0.3")
 end
 
@@ -105,6 +102,4 @@
 
 
-
-
 ### Local Variables:
 ### mode:ruby
Index: /ruby/branches/0.5/lib/adl_parser/lib/adl_exception.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/lib/adl_exception.rb	(revision 290)
+++ /ruby/branches/0.5/lib/adl_parser/lib/adl_exception.rb	(revision 290)
@@ -0,0 +1,14 @@
+module OpenEHR
+  module ADL
+    module Exception
+      class Base < RuntimeError
+      end
+
+      module CADLScanner
+        class Base < RuntimeError
+        end
+      end
+    end
+  end
+end
+
Index: /ruby/branches/0.5/lib/adl_parser/lib/adl_parser.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/lib/adl_parser.rb	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/lib/adl_parser.rb	(revision 290)
@@ -8,4 +8,6 @@
 $:.unshift File.join(File.dirname(__FILE__))
 require 'logger'
+require 'adl_scanner.rb'
+require 'adl_exception.rb'
 
 module OpenEhr
@@ -18,6 +20,4 @@
     LOG.level = Logger::WARN
   end
-  
-  
 
 
@@ -25,8 +25,11 @@
     autoload :Parser, "parser.rb"
     autoload :Validator, "validator.rb"
-    
+
     module Scanner
       module DADL
-        autoload :RootScanner, "scanner.rb"
+        autoload :RootScanner, "adl_scanner.rb"
+      end
+      module CADL
+        autoload :RootScanner, "adl_scanner.rb"
       end
     end
Index: /ruby/branches/0.5/lib/adl_parser/lib/adl_scanner.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/lib/adl_scanner.rb	(revision 290)
+++ /ruby/branches/0.5/lib/adl_parser/lib/adl_scanner.rb	(revision 290)
@@ -0,0 +1,1122 @@
+require 'rubygems'
+require 'yaparc'
+require 'logger'
+require 'adl_parser.rb'
+require 'am.rb'
+require 'rm.rb'
+require 'util.rb'
+
+
+module OpenEHR
+  module ADL
+    module Scanner
+      LOGGER = Logger.new('log/scanner.log')
+      LOGGER.level = Logger::WARN
+
+      class Base
+        attr_accessor :adl_type, :lineno
+        def initialize(adl_type, filename, lineno = 1)
+          @adl_type = adl_type
+          @filename = filename
+          @lineno = lineno
+        end
+
+        def scan(data)
+          raise
+        end
+      end
+
+      #
+      # ADLScanner
+      # 
+      class ADLScanner < Base
+        attr_accessor :adl_type, :lineno, :cadl_scanner, :dadl_scanner, :regex_scanner, :term_constraint_scanner
+
+        @@logger = OpenEHR::ADL::Scanner::LOGGER #Logger.new('log/scanner.log')
+        RESERVED = {
+          'archetype' => :SYM_ARCHETYPE,
+          'adl_version' => :SYM_ADL_VERSION,
+          'controlled' => :SYM_IS_CONTROLLED,
+          'specialize' => :SYM_SPECIALIZE,
+          'concept' => :SYM_CONCEPT,
+          'language' => :SYM_LANGUAGE,
+          'description' => :SYM_DESCRIPTION,
+          'definition' => :SYM_DEFINITION,
+          'invariant' => :SYM_INVARIANT,
+          'ontology' => :SYM_ONTOLOGY,
+          'matches' => :SYM_MATCHES,
+          'is_in' => :SYM_MATCHES,
+          'occurrences' => :SYM_OCCURRENCES,
+          'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE 
+          'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE 
+          'infinity' => :SYM_INFINITY # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY 
+        }
+
+        def initialize(adl_type, filename, lineno = 1)
+          super(adl_type, filename, lineno)
+          @in_interval  = false
+        end
+
+        #
+        # ADLScanner#scan
+        #
+        def scan(data)
+          @@logger.debug("#{__FILE__}:#{__LINE__}: Entering  ADLScanner#scan at #{@filename}:#{@lineno}: data = #{data.inspect}")
+          until data.nil?  do
+            case @adl_type.last
+            when :adl
+              case data
+              when /\A\n/ # carriage return
+                @lineno += 1
+                ;
+              when /\A[ \t\r\f]+/ #just drop it
+                ;
+              when /\A--.*/ # single line comment
+                @lineno += 1
+                @@logger.debug("ADLScanner#scan: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+                ;
+              when /\Adescription/   # description
+                yield :SYM_DESCRIPTION, :SYM_DESCRIPTION
+              when /\Adefinition/   # definition
+                yield :SYM_DEFINITION, :SYM_DEFINITION
+              ###----------/* symbols */ ------------------------------------------------- 
+              when /\A[A-Z][a-zA-Z0-9_]*/
+                yield :V_TYPE_IDENTIFIER, $&
+              when /\A(\w+)-(\w+)-(\w+)\.(\w+)((?:-\w+)*)\.(v\w+)/   #V_ARCHETYPE_ID
+                object_id, rm_originator, rm_name, rm_entity, concept_name, specialisation, version_id = $&, $1, $2, $3, $4, $5, $6
+                archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new(object_id, concept_name, rm_name, rm_entity, rm_originator, specialisation, version_id)
+                yield :V_ARCHETYPE_ID, archetype_id
+              when /\A[a-z][a-zA-Z0-9_]*/
+                word = $&
+                if RESERVED[word]
+                  @@logger.debug("ADLScanner#scan: RESERVED = #{RESERVED[word]} at #{@filename}:#{@lineno}")
+                  yield RESERVED[word], RESERVED[word]
+                elsif #/\A[A-Z][a-zA-Z0-9_]*/
+                  @@logger.debug("ADLScanner#scan: 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
+                  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
+                  assert_at(__FILE__,__LINE__){adl_type == :dadl}
+                  yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
+                end
+              when /\A\{/   # {
+                @adl_type.push(:cadl)
+                @@logger.debug("ADLScanner#scan: SYM_START_CBLOCK")
+                yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
+              when /\A\}/   # }
+                adl_type = @adl_type.pop
+                assert_at(__FILE__,__LINE__){adl_type == :cadl}
+                @@logger.debug("ADLScanner#scan: SYM_END_CBLOCK")
+                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, $&
+              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\._-]+)\]/ #V_QUALIFIED_TERM_CODE_REF form such as [ICD10AM(1998)::F23]
+                yield :V_QUALIFIED_TERM_CODE_REF, $1
+              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"([^"]*)"/m #V_STRING
+                yield :V_STRING, $1
+              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
+                @@logger.debug("ADLScanner#scan: 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[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
+              dadl_scanner = OpenEHR::ADL::Scanner::DADLScanner.new(@adl_type, @filename, @lineno)
+              data = dadl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :cadl
+              cadl_scanner = OpenEHR::ADL::Scanner::CADLScanner.new(@adl_type, @filename, @lineno)
+              data = cadl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :regexp
+              regex_scanner = OpenEHR::ADL::Scanner::RegexScanner.new(@adl_type, @filename, @lineno)
+              data = regex_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :term_constraint
+              term_constraint_scanner = OpenEHR::ADL::Scanner::TermConstraintScanner.new(@adl_type, @filename, @lineno)
+              data = term_constraint_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            else
+              raise
+            end
+          end
+        end
+      end # of ADLScanner
+
+      #
+      # DADLScanner
+      # 
+      class DADLScanner < Base
+        @@logger = OpenEHR::ADL::Scanner::LOGGER #Logger.new('log/scanner.log')
+        RESERVED = {
+          'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE 
+          'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE 
+          'infinity' => :SYM_INFINITY # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY 
+        }
+
+        def initialize(adl_type, filename, lineno = 1)
+          super(adl_type, filename, lineno)
+          @in_interval = false
+          @in_c_domain_type = false
+        end
+
+        #
+        # DADLScanner#scan
+        #
+        def scan(data)
+          @@logger.debug("Entering DADLScanner#scan at #{@filename}:#{@lineno}: @adl_type = #{@adl_type.inspect}, data = #{data.inspect}")
+          until data.nil?  do
+            @@logger.debug("#{@filename}:#{@lineno}: DADLScanner#scan:loop data = #{data.inspect}")
+            case @adl_type.last
+            when :dadl
+              case data
+              when /\A\n/ # carriage return
+                #@@logger.debug("DADLScanner#scan:  carriage return, data = #{data.inspect}")
+                @lineno += 1
+                ;
+              when /\A[ \t\r\f]+/ #just drop it
+                #@@logger.debug("DADLScanner#scan:  white space, data = #{data.inspect}")
+                ;
+              when /\A--.*/ # single line comment
+#                @lineno += 1
+                @@logger.debug("DADLScanner#scan: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+                ;
+              when /\A[a-z][a-zA-Z0-9_]*/
+                word = $&.dup
+                if RESERVED[word.downcase]
+                  yield RESERVED[word.downcase], RESERVED[word.downcase]
+                else
+                  @@logger.debug("DADLScanner#scan: V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}:#{@lineno}")
+                  yield :V_ATTRIBUTE_IDENTIFIER, word #V_ATTRIBUTE_IDENTIFIER /\A[a-z][a-zA-Z0-9_]*/
+                end
+                ###----------/* 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
+                  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
+                  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\|/   # |
+                @@logger.debug("DADLScanner#scan: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
+                if @in_interval
+                  @in_interval = false
+                else
+                  #          @in_interval = false
+                  @in_interval = true
+                end
+                @@logger.debug("DADLScanner#scan: 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, $1
+              when /\A\[/   # [
+                @@logger.debug("DADLScanner#scan: Left_bracket_code at #{@filename}:#{@lineno}")
+                yield :Left_bracket_code, :Left_bracket_code
+              when /\A\]/   # ]
+                @@logger.debug("DADLScanner#scan: Right_bracket_code at #{@filename}:#{@lineno}")
+                yield :Right_bracket_code, :Right_bracket_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-]-
+                @@logger.debug("DADLScanner#scan: V_ISO8601_EXTENDED_DATE_TIME")
+                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]
+                @@logger.debug("DADLScanner#scan: V_ISO8601_EXTENDED_TIME")
+                yield :V_ISO8601_EXTENDED_TIME, $&
+              when /\A\d{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/   #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
+                @@logger.debug("DADLScanner#scan: V_ISO8601_EXTENDED_DATE, #{$&}")
+                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"((?:[^"\\]+|\\.)*)"/ #V_STRING
+                @@logger.debug("DADLScanner#scan: V_STRING, #{$1}")
+                yield :V_STRING, $1
+              when /\A"([^"]*)"/m #V_STRING
+                @@logger.debug("DADLScanner#scan: V_STRING, #{$1}")
+                yield :V_STRING, $1
+              when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/   #V_INTEGER
+                @@logger.debug("DADLScanner#scan: V_INTEGER = #{$&}")
+                yield :V_INTEGER, $&
+              when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
+                yield :V_URI, $&
+              when /\A\S/ #UTF8CHAR
+                yield :UTF8CHAR, $&
+              end
+              data = $' # variable $' receives the string after the match
+            when :adl
+              adl_scanner = OpenEHR::ADL::Scanner::ADLScanner.new(@adl_type, @filename, @lineno)
+              data = adl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :cadl
+              cadl_scanner = OpenEHR::ADL::Scanner::CADLScanner.new(@adl_type, @filename, @lineno)
+              data = cadl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :regexp
+              regex_scanner = OpenEHR::ADL::Scanner::RegexScanner.new(@adl_type, @filename, @lineno)
+              data = regex_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :term_constraint
+              @@logger.debug("#{__FILE__}:#{__LINE__}: scan_dadl: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+              term_constraint_scanner = OpenEHR::ADL::Scanner::TermConstraintScanner.new(@adl_type, @filename, @lineno)
+              data = term_constraint_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            else
+              raise
+            end
+          end
+        end
+      end # of DADLScanner
+
+
+
+      class CADLScanner < Base
+
+        @@logger = OpenEHR::ADL::Scanner::LOGGER #Logger.new('log/scanner.log')        #Logger.new('log/scanner.log')
+        RESERVED = {
+          'then' => :SYM_THEN, # [Tt][Hh][Ee][Nn]
+          'else' => :SYM_ELSE, # [Ee][Ll][Ss][Ee]
+          'and' => :SYM_AND, # [Aa][Nn][Dd]
+          'or' => :SYM_OR, # [Oo][Rr]
+          'xor' => :SYM_XOR, # [Xx][Oo][Rr]
+          'not' => :SYM_NOT, # [Nn][Oo][Tt]
+          'implies' => :SYM_IMPLIES, # [Ii][Mm][Pp][Ll][Ii][Ee][Ss]
+          'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE 
+          'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE 
+          'forall' => :SYM_FORALL, # [Ff][Oo][Rr][_][Aa][Ll][Ll]
+          'exists' => :SYM_EXISTS, # [Ee][Xx][Ii][Ss][Tt][Ss]
+          'existence' => :SYM_EXISTENCE, # [Ee][Xx][Iu][Ss][Tt][Ee][Nn][Cc][Ee]
+          'occurrences' => :SYM_OCCURRENCES, # [Oo][Cc][Cc][Uu][Rr][Rr][Ee][Nn][Cc][Ee][Ss]
+          'cardinality' => :SYM_CARDINALITY, # [Cc][Aa][Rr][Dd][Ii][Nn][Aa][Ll][Ii][Tt][Yy]
+          'ordered' => :SYM_ORDERED, # [Oo][Rr][Dd][Ee][Rr][Ee][Dd]
+          'unordered' => :SYM_UNORDERED, # [Uu][Nn][Oo][Rr][Dd][Ee][Rr][Ee][Dd]
+          'unique' => :SYM_UNIQUE, # [Uu][Nn][Ii][Qq][Uu][Ee]
+          'matches' => :SYM_MATCHES, # [Mm][Aa][Tt][Cc][Hh][Ee][Ss]
+          'is_in' => :SYM_MATCHES, # [Ii][Ss][_][Ii][Nn]
+          'invariant' => :SYM_INVARIANT, # [Ii][Nn][Vv][Aa][Rr][Ii][Aa][Nn][Tt]
+          'infinity' => :SYM_INFINITY, # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY 
+          'use_node' => :SYM_USE_NODE, # [Uu][Ss][Ee][_][Nn][Oo][Dd][Ee]
+          'use_archetype' => :SYM_ALLOW_ARCHETYPE, # [Uu][Ss][Ee][_][Aa][Rr][Cc][Hh][Ee][Tt][Yy][Pp][Ee]
+          'allow_archetype' => :SYM_ALLOW_ARCHETYPE, # [Aa][Ll][Ll][Oo][Ww][_][Aa][Rr][Cc][Hh][Ee][Tt][Yy][Pp][Ee]
+          'include' => :SYM_INCLUDE, # [Ii][Nn][Cc][Ll][Uu][Dd][Ee]
+          'exclude' => :SYM_EXCLUDE # [Ee][Xx][Cc][Ll][Uu][Dd][Ee]
+        }
+
+        def initialize(adl_type, filename, lineno = 1)
+          super(adl_type, filename, lineno)
+          @in_interval = false
+        end
+
+        #
+        # CADLScanner#scan
+        #
+        def scan(data)
+          @@logger.debug("#{__FILE__}:#{__LINE__}: Entering CADLScanner#scan at #{@filename}:#{@lineno}: data = #{data.inspect}")
+          until data.nil?  do
+            @@logger.debug("CADLScanner#scan:  loop data = #{data.inspect}")
+            case @adl_type.last
+            when :cadl
+              case data
+              when /\A\n/ # carriage return
+                @lineno += 1
+                ;
+                #yield :CR, :CR
+              when /\A[ \t\r\f]+/ #just drop it
+                ;
+              when /\A--.*\n/ # single line comment
+                @lineno += 1
+                ;
+              ###----------/* 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,  $&
+                end
+              when /\A\>/   # >
+                if @in_interval
+                  yield :SYM_GT, :SYM_GT
+                else
+                  adl_type = @adl_type.pop
+                  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
+              when /\A\{/   # {
+                @adl_type.push(:cadl)
+                @@logger.debug("CADLScanner#scan: entering cADL at #{@filename}:#{@lineno}")
+                yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
+              when /\A\}/   # }
+                adl_type = @adl_type.pop
+                assert_at(__FILE__,__LINE__){adl_type == :cadl}
+                @@logger.debug("CADLScanner#scan: 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\|/   # |
+                @@logger.debug("CADLScanner#scan: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
+                if @in_interval
+                  @in_interval = false
+                else
+                  #          @in_interval = false
+                  @in_interval = true
+                end
+                @@logger.debug("CADLScanner#scan: 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, $1
+              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\(\)\._\-]+)::[ \t\n]*/
+                @adl_type.push(:term_constraint)
+                yield :START_TERM_CODE_CONSTRAINT, $1
+              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 /\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 such as PnYnMnWnDTnnHnnMnnS
+              when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?/   #V_ISO8601_DURATION such as PnYnMnWnDTnnHnnMnnS
+                yield :V_ISO8601_DURATION, $&
+              when /\AP[yY]?[mM]?[wW]?[dD]?T[hH]?[mM]?[sS]?/   #V_ISO8601_DURATION_CONSTRAINT_PATTERNo
+                yield :V_ISO8601_DURATION_CONSTRAINT_PATTERN, $&
+              when /\A[a-z][a-zA-Z0-9_]*/
+                word = $&.dup
+                if RESERVED[word.downcase]
+                  yield RESERVED[word.downcase], RESERVED[word.downcase]
+                else
+                  @@logger.debug("CADLScanner#scan: 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 RESERVED[word.downcase]
+                  yield RESERVED[word.downcase], 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
+                @@logger.debug("CADLScanner#scan: 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
+                yield :V_STRING, $1
+              when /\A"([^"]*)"/m #V_STRING
+                yield :V_STRING, $1
+              when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
+                yield :V_URI, $&
+              when /\A\S/ #UTF8CHAR
+                yield :UTF8CHAR, $&
+              when /\A.+/ #
+                raise OpenEHR::ADL::Exception::CADLScanner::Base.new, "can't handle #{data.inspect}"
+              end
+              data = $' # variable $' receives the string after the match
+            when :adl
+              adl_scanner = OpenEHR::ADL::Scanner::ADLScanner.new(@adl_type, @filename, @lineno)
+              data = adl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :dadl
+              dadl_scanner = OpenEHR::ADL::Scanner::DADLScanner.new(@adl_type, @filename, @lineno)
+              data = dadl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :regexp
+              regex_scanner = OpenEHR::ADL::Scanner::RegexScanner.new(@adl_type, @filename, @lineno)
+              data = regex_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :term_constraint
+              @@logger.debug("Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+              term_constraint_scanner = OpenEHR::ADL::Scanner::TermConstraintScanner.new(@adl_type, @filename, @lineno)
+              data = term_constraint_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            else
+              raise OpenEHR::ADL::Exception::CADLScanner.new, "unexpected adl_type: #{@adl_type.last}"
+            end
+          end # of until
+        end
+      end # of CADLScanner
+
+
+      #
+      # RegexScanner
+      # 
+      class RegexScanner < Base
+
+        @@logger = OpenEHR::ADL::Scanner::LOGGER #Logger.new('log/scanner.log')        #Logger.new('log/scanner.log')
+        
+        def initialize(adl_type, filename, lineno = 1)
+          super(adl_type, filename, lineno)
+        end
+
+        def scan(data)
+          @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_regexp at #{@filename}:#{@lineno}: data = #{data.inspect}")
+          until data.nil?  do
+            case @adl_type.last
+            when :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
+              adl_scanner = OpenEHR::ADL::Scanner::ADLScanner.new(@adl_type, @filename, @lineno)
+              data = adl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :dadl
+              dadl_scanner = OpenEHR::ADL::Scanner::DADLScanner.new(@adl_type, @filename, @lineno)
+              data = dadl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :cadl
+              cadl_scanner = OpenEHR::ADL::Scanner::CADLScanner.new(@adl_type, @filename, @lineno)
+              data = cadl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :term_constraint
+              #@@logger.debug("#{__FILE__}:#{__LINE__}: scan_regexp: Entering scan_term_constraint at #{@filename}:#{@lineno}")
+              term_constraint_scanner = OpenEHR::ADL::Scanner::TermConstraintScanner.new(@adl_type, @filename, @lineno)
+              data = term_constraint_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            else
+              raise
+            end
+          end
+        end
+      end # of RegexScanner
+
+      #
+      # TermConstraintScanner
+      # 
+      class TermConstraintScanner < Base
+        @@logger = OpenEHR::ADL::Scanner::LOGGER #Logger.new('log/scanner.log')        #Logger.new('log/scanner.log')
+        def initialize(adl_type, filename, lineno = 1)
+          super(adl_type, filename, lineno)
+        end
+
+        def scan(data)
+          @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_term_constraint")
+          until data.nil?  do
+            case @adl_type.last
+            when :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
+                @@logger.debug("#{__FILE__}:#{__LINE__}: scan_term_constraint: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+                ;
+              when /\A([a-zA-Z0-9\._\-])+[ \t]*,/ # match any line, with ',' termination
+                yield :TERM_CODE, $1
+              when /\A([a-zA-Z0-9\._\-])+[ \t]*;/ # match second last line with ';' termination (assumed value)
+                yield :TERM_CODE, $1
+              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, $1
+              else
+                raise "data = #{data}"
+              end
+              data = $' # variable $' receives the string after the match
+            when :adl
+              adl_scanner = OpenEHR::ADL::Scanner::ADLScanner.new(@adl_type, @filename, @lineno)
+              data = adl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :dadl
+              dadl_scanner = OpenEHR::ADL::Scanner::DADLScanner.new(@adl_type, @filename, @lineno)
+              data = dadl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            when :cadl
+              cadl_scanner = OpenEHR::ADL::Scanner::CADLScanner.new(@adl_type, @filename, @lineno)
+              data = cadl_scanner.scan(data) do |sym, val|
+                yield sym, val
+              end
+            else
+              raise
+            end
+          end
+        end
+      end # of TermConstraintScanner
+
+    end
+  end
+end
+
+__END__
+
+
+
+#       module Common
+#         class START_TERM_CODE_CONSTRAINT
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/[ \t\n]*\[([a-zA-Z0-9\(\)\._\-]+)::[ \t\n]*/)) do |match|
+#                 OpenEHR::LOG.info("START_TERM_CODE_CONSTRAINT: #{match}")
+#                 [:START_TERM_CODE_CONSTRAINT, match]
+#               end
+#             end
+#           end
+#         end
+
+#         # /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/  #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
+#         class V_QUALIFIED_TERM_CODE_REF
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/)) do |match|
+#                 OpenEHR::LOG.info("V_QUALIFIED_TERM_CODE_REF: #{match}")
+#                 [:V_QUALIFIED_TERM_CODE_REF, match]
+#               end
+#             end
+#           end
+#         end
+        
+#         class V_LOCAL_TERM_CODE_REF
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/)) do |match|
+#                 OpenEHR::LOG.info("V_TERM_CODE_REF: #{match}")
+#                 [:V_LOCAL_TERM_CODE_REF, match]
+#               end
+#             end
+#           end
+#         end
+
+#         class ERR_V_QUALIFIED_TERM_CODE_REF
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/)) do |match|
+#                 OpenEHR::LOG.info("ERR_V_QUALIFIED_TERM_CODE_REF: #{match}")
+#                 [:ERR_V_QUALIFIED_TERM_CODE_REF, match]
+#               end
+#             end
+#           end
+#         end
+
+#         class V_TYPE_IDENTIFIER
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A[A-Z][a-zA-Z0-9_]*/)) do |match|
+#                 OpenEHR::LOG.info("V_TYPE_IDENTIFIER: #{match}")
+#                 [:V_TYPE_IDENTIFIER, match]
+#               end
+#             end
+#           end
+#         end
+
+#         class V_GENERIC_TYPE_IDENTIFIER
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/)) do |match|
+#                 OpenEHR::LOG.info("V_GENERIC_TYPE_IDENTIFIER: #{match}")
+#                 [:V_GENERIC_TYPE_IDENTIFIER, match]
+#               end
+#             end
+#           end
+#         end
+
+
+#         class V_LOCAL_CODE
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\Aa[ct][0-9.]+/)) do |match|
+#                 OpenEHR::LOG.info("V_LOCAL_CODE: #{match}")
+#                 [:V_LOCAL_CODE, match]
+#               end
+#             end
+#           end
+#         end
+
+#         class V_STRING
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A"([^"]*)"/m)) do |match|
+#                 OpenEHR::LOG.info("V_STRING: #{match}")
+#                 [:V_STRING, match]
+#               end
+#             end
+#           end
+#         end
+
+#         class V_REAL
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+/)) do |match|
+#                 OpenEHR::LOG.info("V_REAL: #{match}")
+#                 [:V_REAL, match]
+#               end
+#             end
+#           end
+#         end
+
+#         #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
+#         class V_ISO8601_DURATION
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(
+#                                 Yaparc::Alt.new(Yaparc::Regex.new(/\AP([0-9]+|[yY])?([0-9]+|[mM])?([0-9]+|[wW])?([0-9]+|[dD])?T([0-9]+|[hH])?([0-9]+|[mM])?([0-9]+|[sS])?/),
+#                                                 Yaparc::Regex.new(/\AP([0-9]+|[yY])?([0-9]+|[mM])?([0-9]+|[wW])?([0-9]+|[dD])?/))) do |match|
+#                 OpenEHR::LOG.info("V_ISO8601_DURATION: #{match}")
+#                 [:V_ISO8601_DURATION, match]
+#               end
+#             end
+#           end
+#         end
+
+#       end # of Common
+
+#       module DADL
+#         # c.f. http://www.openehr.org/svn/ref_impl_eiffel/TRUNK/components/adl_parser/src/syntax/adl/parser/adl_scanner.l
+#         RESERVED = {
+#           'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE 
+#           'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE 
+#           'infinity' => :SYM_INFINITY # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY 
+#         }
+#         #
+#         # DADL::RootScanner
+#         #
+#         class RootScanner
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Alt.new(Reserved.new,
+#                               OpenEHR::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF.new,
+#                               OpenEHR::ADL::Scanner::Common::V_LOCAL_TERM_CODE_REF.new,
+#                               OpenEHR::ADL::Scanner::Common::ERR_V_QUALIFIED_TERM_CODE_REF.new,
+#                               OpenEHR::ADL::Scanner::Common::V_TYPE_IDENTIFIER.new,
+#                               OpenEHR::ADL::Scanner::Common::V_GENERIC_TYPE_IDENTIFIER.new,
+#                               OpenEHR::ADL::Scanner::Common::V_STRING.new,
+#                               OpenEHR::ADL::Scanner::Common::V_LOCAL_CODE.new,
+#                               OpenEHR::ADL::Scanner::Common::V_REAL.new,
+#                               OpenEHR::ADL::Scanner::Common::V_ISO8601_DURATION.new#,
+#                               #OpenEHR::ADL::Scanner::Common::START_TERM_CODE_CONSTRAINT.new
+#                               )
+#             end
+#           end
+#         end
+
+#         #  <DADL::Reserved class>
+#         class Reserved
+#           include Yaparc::Parsable
+          
+#           def initialize
+#             @parser = lambda do |input|
+#               reserved_parsers = OpenEHR::ADL::Scanner::DADL::RESERVED.map do |keyword| 
+#                 Yaparc::Tokenize.new(
+#                                      Yaparc::Literal.new(keyword[0],false)
+#                                      )
+#               end
+#               Yaparc::Alt.new(Yaparc::Apply.new(Yaparc::Alt.new(*reserved_parsers)) do |match|
+#                                 OpenEHR::LOG.info("Reserved: #{match}")
+#                                 [OpenEHR::ADL::Scanner::DADL::RESERVED[match], OpenEHR::ADL::Scanner::DADL::RESERVED[match]]
+#                               end,
+#                               Yaparc::Apply.new(Yaparc::Regex.new(/\A[a-z][a-zA-Z0-9_]*/)) do |match|
+#                                 OpenEHR::LOG.info("V_ATTRIBUTE_IDENTIFIER: #{match}")
+#                                 [:V_ATTRIBUTE_IDENTIFIER, match]
+#                               end)
+#             end
+#           end
+#         end
+#       end # of DADL
+
+#       module CADL
+#         # c.f. http://www.openehr.org/svn/ref_impl_eiffel/TRUNK/components/adl_parser/src/syntax/cadl/parser/cadl_scanner.l
+#         RESERVED = {
+#           'ordered' => :SYM_ORDERED, # [Oo][Rr][Dd][Ee][Rr][Ee][Dd]
+#           'unordered' => :SYM_UNORDERED, # [Uu][Nn][Oo][Rr][Dd][Ee][Rr][Ee][Dd]
+#           'then' => :SYM_THEN, # [Tt][Hh][Ee][Nn]
+#           'else' => :SYM_ELSE, # [Ee][Ll][Ss][Ee]
+#           'and' => :SYM_AND, # [Aa][Nn][Dd]
+#           'or' => :SYM_OR, # [Oo][Rr]
+#           'xor' => :SYM_XOR, # [Xx][Oo][Rr]
+#           'not' => :SYM_NOT, # [Nn][Oo][Tt]
+#           'implies' => :SYM_IMPLIES, # [Ii][Mm][Pp][Ll][Ii][Ee][Ss]
+#           'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE 
+#           'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE 
+#           'forall' => :SYM_FORALL, # [Ff][Oo][Rr][_][Aa][Ll][Ll]
+#           'exists' => :SYM_EXISTS, # [Ee][Xx][Ii][Ss][Tt][Ss]
+#           'existence' => :SYM_EXISTENCE, # [Ee][Xx][Iu][Ss][Tt][Ee][Nn][Cc][Ee]
+#           'occurrences' => :SYM_OCCURRENCES, # [Oo][Cc][Cc][Uu][Rr][Rr][Ee][Nn][Cc][Ee][Ss]
+#           'cardinality' => :SYM_CARDINALITY, # [Cc][Aa][Rr][Dd][Ii][Nn][Aa][Ll][Ii][Tt][Yy]
+#           'unique' => :SYM_UNIQUE, # [Uu][Nn][Ii][Qq][Uu][Ee]
+#           'matches' => :SYM_MATCHES, # [Mm][Aa][Tt][Cc][Hh][Ee][Ss]
+#           'is_in' => :SYM_MATCHES, # [Ii][Ss][_][Ii][Nn]
+#           'invariant' => :SYM_INVARIANT, # [Ii][Nn][Vv][Aa][Rr][Ii][Aa][Nn][Tt]
+#           'infinity' => :SYM_INFINITY, # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY 
+#           'use_node' => :SYM_USE_NODE, # [Uu][Ss][Ee][_][Nn][Oo][Dd][Ee]
+#           'use_archetype' => :SYM_ALLOW_ARCHETYPE, # [Uu][Ss][Ee][_][Aa][Rr][Cc][Hh][Ee][Tt][Yy][Pp][Ee]
+#           'allow_archetype' => :SYM_ALLOW_ARCHETYPE, # [Aa][Ll][Ll][Oo][Ww][_][Aa][Rr][Cc][Hh][Ee][Tt][Yy][Pp][Ee]
+#           'include' => :SYM_INCLUDE, # [Ii][Nn][Cc][Ll][Uu][Dd][Ee]
+#           'exclude' => :SYM_EXCLUDE # [Ee][Xx][Cc][Ll][Uu][Dd][Ee]
+#         }
+
+#         #V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN, /\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]/
+#         class V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\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]/)) do |match|
+#                 OpenEHR::LOG.info("V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN: #{match}")
+#                 [:V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN, match]
+#               end
+#             end
+#           end
+#         end
+
+#         #V_ISO8601_DATE_CONSTRAINT_PATTERN  /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X]/
+#         class V_ISO8601_DATE_CONSTRAINT_PATTERN
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X]/)) do |match|
+#                 OpenEHR::LOG.info("V_ISO8601_DATE_CONSTRAINT_PATTERN: #{match}")
+#                 [:V_ISO8601_DATE_CONSTRAINT_PATTERN, match]
+#               end
+#             end
+#           end
+#         end
+
+#         #V_ISO8601_TIME_CONSTRAINT_PATTERN /\A[hH][hH]:[mM?X][mM?X]:[sS?X][sS?X]/
+#         class V_ISO8601_TIME_CONSTRAINT_PATTERN
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A[hH][hH]:[mM?X][mM?X]:[sS?X][sS?X]/)) do |match|
+#                 OpenEHR::LOG.info("V_ISO8601_TIME_CONSTRAINT_PATTERN: #{match}")
+#                 [:V_ISO8601_TIME_CONSTRAINT_PATTERN, match]
+#               end
+#             end
+#           end
+#         end
+
+#         #V_ISO8601_DURATION_CONSTRAINT_PATTERN 
+#         class V_ISO8601_DURATION_CONSTRAINT_PATTERN
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Alt.new(Yaparc::Regex.new(/\AP[yY]?[mM]?[wW]?[dD]?T[hH]?[mM]?[sS]?/),
+#                                                 Yaparc::Regex.new(/\AP[yY]?[mM]?[wW]?[dD]?/))) do |match|
+#                 OpenEHR::LOG.info("V_ISO8601_DURATION_CONSTRAINT_PATTERN: #{match}")
+#                 [:V_ISO8601_DURATION_CONSTRAINT_PATTERN, match]
+#               end
+#             end
+#           end
+#         end
+
+#         #V_C_DOMAIN_TYPE /\A[A-Z][a-zA-Z0-9_]*[ \n]*\</
+#         class V_C_DOMAIN_TYPE
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Apply.new(Yaparc::Regex.new(/\A[A-Z][a-zA-Z0-9_]*[ \n]*\</)) do |match|
+#                 OpenEHR::LOG.info("V_C_DOMAIN_TYPE: #{match}")
+#                 [:START_V_C_DOMAIN_TYPE_BLOCK, match]
+#               end
+#             end
+#           end
+#         end
+
+#         #
+#         # CADL::RootScanner
+#         #
+#         class RootScanner
+#           include Yaparc::Parsable
+#           def initialize
+#             @parser = lambda do |input|
+#               Yaparc::Alt.new(V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN.new,
+#                               V_ISO8601_DATE_CONSTRAINT_PATTERN.new,
+#                               V_ISO8601_TIME_CONSTRAINT_PATTERN.new,
+#                               OpenEHR::ADL::Scanner::Common::V_ISO8601_DURATION.new,
+#                               V_C_DOMAIN_TYPE.new,
+#                               V_ISO8601_DURATION_CONSTRAINT_PATTERN.new,
+#                               Reserved.new,
+#                               OpenEHR::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF.new,
+#                               OpenEHR::ADL::Scanner::Common::V_LOCAL_TERM_CODE_REF.new,
+#                               OpenEHR::ADL::Scanner::Common::ERR_V_QUALIFIED_TERM_CODE_REF.new,
+#                               OpenEHR::ADL::Scanner::Common::V_TYPE_IDENTIFIER.new,
+#                               OpenEHR::ADL::Scanner::Common::V_GENERIC_TYPE_IDENTIFIER.new,
+#                               OpenEHR::ADL::Scanner::Common::V_STRING.new,
+#                               OpenEHR::ADL::Scanner::Common::V_LOCAL_CODE.new,
+#                               OpenEHR::ADL::Scanner::Common::V_REAL.new,
+#                               OpenEHR::ADL::Scanner::Common::V_ISO8601_DURATION.new#,
+#                               #OpenEHR::ADL::Scanner::Common::START_TERM_CODE_CONSTRAINT.new
+#                               )
+#             end
+#           end
+#         end
+
+#         # <CADL::Reserved class>
+#         class Reserved
+#           include Yaparc::Parsable
+          
+#           def initialize
+#             @parser = lambda do |input|
+#               orderd_reserved = RESERVED.keys.sort{|x,y| y.length <=> x.length  }
+#               reserved_parsers = orderd_reserved.map do |keyword| 
+#                 Yaparc::Literal.new(keyword,false)
+#               end
+#               Yaparc::Alt.new(Yaparc::Apply.new(Yaparc::Alt.new(*reserved_parsers)) do |match|
+#                                 OpenEHR::LOG.info("Reserved: #{match}")
+#                                 [OpenEHR::ADL::Scanner::CADL::RESERVED[match], OpenEHR::ADL::Scanner::CADL::RESERVED[match]]
+#                               end,
+#                               Yaparc::Apply.new(Yaparc::Regex.new(/\A[a-z][a-zA-Z0-9_]*/)) do |match|
+#                                 OpenEHR::LOG.info("V_ATTRIBUTE_IDENTIFIER: #{match}")
+#                                 [:V_ATTRIBUTE_IDENTIFIER, match]
+#                               end)
+#             end
+#           end
+#         end
+
+#       end
+
+
Index: /ruby/branches/0.5/lib/adl_parser/lib/parser.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/lib/parser.rb	(revision 289)
+++ /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]
Index: /ruby/branches/0.5/lib/adl_parser/lib/parser.y
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/lib/parser.y	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/lib/parser.y	(revision 290)
@@ -40,4 +40,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]
@@ -45,4 +46,5 @@
     archetype = OpenEHR::AM::Archetype::ARCHETYPE.create(
                                                          :archetype_id => archetype_id,
+                                                         :parent_archtype_id => parent_archtype_id,
                                                          :adl_version => adl_version,
                                                          :concept => concept,
@@ -53,5 +55,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
   }
@@ -104,4 +106,7 @@
 arch_specialisation: #-- empty is ok
   | SYM_SPECIALIZE V_ARCHETYPE_ID
+  {
+    result = {:parent_archtype_id => val[1]}
+  }
   | SYM_SPECIALIZE error
 
@@ -150,5 +155,5 @@
   {
     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]
   }
@@ -201,12 +206,18 @@
 
 #------------------------- node types -----------------------
-
-c_object: v_c_domain_type
-  {
-    result = val[0]
-  }
-  | c_complex_object
-  {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")
+### http://www.openehr.org/svn/ref_impl_eiffel/TRUNK/components/adl_parser/src/syntax/cadl/parser/cadl_validator.html
+### c_object:  c_complex_object
+### | archetype_internal_ref
+### | archetype_slot
+### | constraint_ref
+### | c_code_phrase
+### | c_ordinal
+### | c_primitive_object
+### | V_C_DOMAIN_TYPE
+### | ERR_C_DOMAIN_TYPE
+### | error
+c_object: c_complex_object
+  {
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -241,4 +252,9 @@
     result = val[0]
   }
+  | v_c_domain_type
+  {
+    result = val[0]
+  }
+
 #  | v_c_domain_type
 #  | V_C_DOMAIN_TYPE
@@ -297,5 +313,5 @@
 c_primitive: c_integer
   {
-    @@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
@@ -306,30 +322,30 @@
   | c_real
   {
-    @@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
   }
   | c_date
   {
-    @@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
   }
   | c_time
   {
-    @@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
   }
   | c_date_time
   {
-    @@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
   }
   | c_duration
   {
-    @@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
   }
   | c_string
   {
-    @@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
   }
@@ -337,5 +353,5 @@
   {
     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]
   }
@@ -377,5 +393,5 @@
 c_attr_head: V_ATTRIBUTE_IDENTIFIER c_existence
   {
-    @@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],
@@ -387,5 +403,5 @@
   {
     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],
@@ -469,5 +485,5 @@
 attr_val: attr_id SYM_EQ object_block
   {
-    @@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]}
   }
@@ -475,5 +491,5 @@
 attr_id: V_ATTRIBUTE_IDENTIFIER
   {
-    @@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]
   }
@@ -514,5 +530,4 @@
 multiple_attr_object_block_head: SYM_START_DBLOCK
   { 
-    @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -529,11 +544,11 @@
 keyed_object: object_key SYM_EQ object_block
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
-    result = {:object_key => val[0], :object_block => val[1]}
+    @@logger.debug("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]} at #{@filename}:#{@lineno}")
+    result = {:object_key => val[0], :object_block => val[2]}
   }
 
 object_key: Left_bracket_code simple_value Right_bracket_code
   {
-    @@log.info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
+    @@logger.debug("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
     result = val[1]
   }
@@ -548,12 +563,12 @@
   }
 
-untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # <>
-  {
-    @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
+untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # >
+  {
+    @@logger.debug("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:single_attr_object_complex_head => val[0]}
   }
   | single_attr_object_complex_head attr_vals SYM_END_DBLOCK
   {
-    @@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]}
   }
@@ -561,15 +576,15 @@
 primitive_object_block: untyped_primitive_object_block
   {
-    @@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]}
   }
   | type_identifier untyped_primitive_object_block
   {
-    @@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]}
   }
 untyped_primitive_object_block: SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK
   {
-    @@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]
   }
@@ -596,50 +611,50 @@
 simple_value: string_value
   {
-    @@log.info("string_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("string_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | integer_value
   {
-    @@log.info("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | real_value
   {
-    @@log.info("real_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("real_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | boolean_value
   {
-    @@log.info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | character_value
   {
-    @@log.info("character_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("character_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | date_value
   {
-    @@log.info("date_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("date_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | time_value
   {
-    @@log.info("time_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("time_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | date_time_value
   {
-    @@log.info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | duration_value
   {
-    @@log.info("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | uri_value
   {
-    @@log.info("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -664,10 +679,10 @@
 type_identifier: V_TYPE_IDENTIFIER
   {
-    @@log.info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | V_GENERIC_TYPE_IDENTIFIER
   {
-    @@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]
   }
@@ -675,5 +690,5 @@
 string_value: V_STRING
   {
-    @@log.info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -790,4 +805,7 @@
 
 date_value: V_ISO8601_EXTENDED_DATE
+  { 
+    result = val[0]
+  }
 
 date_list_value: date_value Comma_code date_value
@@ -839,5 +857,5 @@
 duration_value: V_ISO8601_DURATION
   {
-    @@log.info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -859,5 +877,5 @@
 term_code: V_QUALIFIED_TERM_CODE_REF
   {
-    @@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]
   }
@@ -869,5 +887,5 @@
 uri_value: V_URI
   {
-    @@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]
   }
@@ -939,9 +957,9 @@
 path_segment: V_ATTRIBUTE_IDENTIFIER V_LOCAL_TERM_CODE_REF
   {
-    @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
   }
   | V_ATTRIBUTE_IDENTIFIER
   {
-    @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
   }
 
@@ -1116,5 +1134,5 @@
   {
     @in_interval = false
-    @@log.info("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
   }
 
@@ -1129,10 +1147,17 @@
   }
 
-#term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body Right_bracket_code
+#                             [[a-zA-Z0-9\(\)\._\-]+::[ \t\n]*          [[a-zA-Z0-9\._\-]*[ \t]*]
 term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT
+  {
+    @@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]
+  }
+
+
 term_code_body: # empty
   | TERM_CODE
   | term_code_body TERM_CODE
-### term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT
 ### term_code_body: TERM_CODE
 ###   | term_code_body TERM_CODE
@@ -1150,5 +1175,5 @@
   | V_ATTRIBUTE_IDENTIFIER
   {
-    @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
       result = val[0]
   }
@@ -1171,9 +1196,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
 
@@ -1189,13 +1214,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 */ --------------------------------------------- 
@@ -1257,25 +1280,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
@@ -1284,664 +1294,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
 
 
@@ -1964,5 +1314,5 @@
 
 
-
+__END__
 
 
Index: /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl	(revision 290)
@@ -10,5 +10,5 @@
 		["name"] = <"Thomas Beale">
 		["organisation"] = <"Ocean Informatics">
-		["date"] = <"2005-10-10">
+		["date"] = <"10/10/2005">
 	>
 	details = <
Index: /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl	(revision 290)
@@ -25,5 +25,5 @@
         ["name"] = <"Sam Heard">
         ["organisation"] = <"Ocean Informatics">
-        ["date"] = <"2004-05-18">
+        ["date"] = <"18/05/2004">
         ["email"] = <"sam.heard@oceaninformatics.biz">
     >
@@ -45,8 +45,8 @@
         ["de"] = <
             language = <[ISO_639-1::de]>
-            purpose = <"Zur Dokumentation des Apgar Wertes oder Beurteilung f%Gï¿½%@r Neugeborene. Der zu Grunde liegende Zeitpunkt der Ereignisreihe ist immer die Geburt.">
-            use = <"Erm%Gï¿½%@glicht die Dokumentation des Wohlergehens des S%Gï¿½%@uglings 1, 2, 5 und/ oder 10 Minuten nach der Geburt. Die Summe kann einzeln dokumentiert werden - falls nur diese verf%Gï¿½%@gbar ist - es sollten aber alle f%Gï¿½%@nf Zahlenwerte vervollst%Gï¿½%@ndigt werden, damit die Summe errechnet werden kann. Die Gesamtsumme ist die Summe der f%Gï¿½%@nf Zahlenwerte (minimal 0, maximal 10).">
+            purpose = <"Zur Dokumentation des Apgar Wertes oder Beurteilung f%G�%@r Neugeborene. Der zu Grunde liegende Zeitpunkt der Ereignisreihe ist immer die Geburt.">
+            use = <"Erm%G�%@glicht die Dokumentation des Wohlergehens des S%G�%@uglings 1, 2, 5 und/ oder 10 Minuten nach der Geburt. Die Summe kann einzeln dokumentiert werden - falls nur diese verf%G�%@gbar ist - es sollten aber alle f%G�%@nf Zahlenwerte vervollst%G�%@ndigt werden, damit die Summe errechnet werden kann. Die Gesamtsumme ist die Summe der f%G�%@nf Zahlenwerte (minimal 0, maximal 10).">
             keywords = <"Apgar", "Neugeborenes", "Index", "Wert">
-            misuse = <"Nur teilweise Vervollst%Gï¿½%@ndigung der Werte und Addieren von weniger als f%Gï¿½%@nf Werten zur Gesamtsumme.">
+            misuse = <"Nur teilweise Vervollst%G�%@ndigung der Werte und Addieren von weniger als f%G�%@nf Werten zur Gesamtsumme.">
         >
     >
@@ -414,5 +414,5 @@
             items = <
                 ["at0000"] = <
-                    description = <"Klinischer Wert, abgeleitet von der Beurteilung der Atmung, der Hautfarbe, dem Muskeltonus, der Herzfrequenz und der Reaktion von Reflexen, %Gï¿½%@blicherweise 1, 5 und 10 Minuten nach der Geburt erhoben">
+                    description = <"Klinischer Wert, abgeleitet von der Beurteilung der Atmung, der Hautfarbe, dem Muskeltonus, der Herzfrequenz und der Reaktion von Reflexen, %G�%@blicherweise 1, 5 und 10 Minuten nach der Geburt erhoben">
                     text = <"Apgar Wert">
                 >
@@ -438,10 +438,10 @@
                 >
                 ["at0007"] = <
-                    description = <"Herzfrequenz von weniger als 100 Schl%Gï¿½%@gen pro Minute">
-                    text = <"Weniger als 100 Schl%Gï¿½%@ge pro Minute">
+                    description = <"Herzfrequenz von weniger als 100 Schl%G�%@gen pro Minute">
+                    text = <"Weniger als 100 Schl%G�%@ge pro Minute">
                 >
                 ["at0008"] = <
-                    description = <"Herzfrequenz von mehr als oder genau 100 Schl%Gï¿½%@gen pro Minute">
-                    text = <"Mehr als oder genau 100 Schl%Gï¿½%@ge pro Minute">
+                    description = <"Herzfrequenz von mehr als oder genau 100 Schl%G�%@gen pro Minute">
+                    text = <"Mehr als oder genau 100 Schl%G�%@ge pro Minute">
                 >
                 ["at0009"] = <
@@ -478,34 +478,34 @@
                 >
                 ["at0017"] = <
-                    description = <"Beurteilung der Reaktion des Neugeborenen auf die Absaugung der Nasenl%Gï¿½%@cher">
+                    description = <"Beurteilung der Reaktion des Neugeborenen auf die Absaugung der Nasenl%G�%@cher">
                     text = <"Reflexantwort">
                 >
                 ["at0018"] = <
-                    description = <"kein W%Gï¿½%@rgen oder keine Reaktion auf das Absaugen der Atemwege">
+                    description = <"kein W%G�%@rgen oder keine Reaktion auf das Absaugen der Atemwege">
                     text = <"Keine Reaktion auf die Absaugung der Atemwege">
                 >
                 ["at0019"] = <
                     description = <"Grimasse als einzige Reaktion auf das Absaugen der Atemwege">
-                    text = <"Grimasse w%Gï¿½%@hrend der Absaugung der Atemwege">
+                    text = <"Grimasse w%G�%@hrend der Absaugung der Atemwege">
                 >
                 ["at0020"] = <
-                    description = <"Grimasse und husten, niesen oder w%Gï¿½%@rgen als Reaktion auf die Absaugung der Atemwege">
-                    text = <"Grimasse und Husten/Niesen w%Gï¿½%@hrend der Absaugung der Atemwege ">
+                    description = <"Grimasse und husten, niesen oder w%G�%@rgen als Reaktion auf die Absaugung der Atemwege">
+                    text = <"Grimasse und Husten/Niesen w%G�%@hrend der Absaugung der Atemwege ">
                 >
                 ["at0021"] = <
-                    description = <"Die Farbe der Haut am K%Gï¿½%@rper, am Rumpf und an den Gliedern">
+                    description = <"Die Farbe der Haut am K%G�%@rper, am Rumpf und an den Gliedern">
                     text = <"Hautfarbe">
                 >
                 ["at0022"] = <
-                    description = <"Der K%Gï¿½%@rper ist blass oder blau gef%Gï¿½%@rbt">
-                    text = <"Gesamter K%Gï¿½%@rper ist blau oder blass">
+                    description = <"Der K%G�%@rper ist blass oder blau gef%G�%@rbt">
+                    text = <"Gesamter K%G�%@rper ist blau oder blass">
                 >
                 ["at0023"] = <
-                    description = <"Der K%Gï¿½%@rper ist rosig, H%Gï¿½%@nde und F%Gï¿½ï¿½%@e sind blass oder blau">
-                    text = <"Gesunde K%Gï¿½%@rperfarbe, blaue H%Gï¿½%@nde oder F%Gï¿½ï¿½%@e">
+                    description = <"Der K%G�%@rper ist rosig, H%G�%@nde und F%G��%@e sind blass oder blau">
+                    text = <"Gesunde K%G�%@rperfarbe, blaue H%G�%@nde oder F%G��%@e">
                 >
                 ["at0024"] = <
-                    description = <"Rosige oder gesunde F%Gï¿½%@rbung des gesamten K%Gï¿½%@rpers">
-                    text = <"Vollst%Gï¿½%@ndig gesunde oder rosige Farbe">
+                    description = <"Rosige oder gesunde F%G�%@rbung des gesamten K%G�%@rpers">
+                    text = <"Vollst%G�%@ndig gesunde oder rosige Farbe">
                 >
                 ["at0025"] = <
Index: /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl	(revision 290)
+++ /ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl	(revision 290)
@@ -0,0 +1,162 @@
+archetype (adl_version=1.4)
+	openEHR-EHR-OBSERVATION.body_mass_index.v1
+
+concept
+	[at0000]	-- Body mass index
+language
+	original_language = <[ISO_639-1::en]>
+description
+	original_author = <
+		["name"] = <"Sam Heard">
+		["organisation"] = <"Ocean Informatics">
+		["email"] = <"sam.heard@oceaninformatics.com">
+		["date"] = <"22/03/2006">
+	>
+	details = <
+		["en"] = <
+			language = <[ISO_639-1::en]>
+			purpose = <"To record the Body Mass Index (BMI) of a person.
+Body Mass Index is a calculated ratio describing how an individual's body weight relates to the weight that is regarded as normal, or desirable, for the individual's height. ">
+			use = <"Use to record the Body Mass Index of both adults and children.  
+Use to enter the Body Mass Index either manually (ie calculated and directly entered by the clinician), or automatically (ie calculation and entry is done automatically by a software application, based on separate height and weight measurements).
+Formulas: Body Mass Index is commonly calculated as weight (kg) / [height (m) squared]. This is the assumed formula unless otherwise specified in the Formula element within Protocol. Alternatively estimate Body Mass Index using pounds and inches: weight (lb) / [height (in) squared] x 703 (with ounces (oz) and fractions changed to decimal values).
+In some situations the Body Mass Index formula is corrected eg for use in amputees - this specific formula can be recorded as part of the protocol.  Alternatively the common Body Mass Index calculation can be used with amputees and similar injuries or disabilities if using adjusted height and/or adjusted weight, as appropriate, rather than actual height and weight.   See openEHR-EHR-OBSERVATION.height-adjusted and openEHR-EHR-OBSERVATION.body_weight-adjusted.
+See WHO reference re adjusting height/length for Body Mass Index in paediatrics. 
+In children and teens, BMI needs to be assessed using age-related reference charts. 
+">
+			keywords = <"obesity", "index", "body mass", "BMI", "anorexia", "Quetelet", "malnutrition", "failure to thrive", "bulimia">
+			misuse = <"Not intended to record information regarding Body Mass Index percentiles - these will be recorded in separate archetypes.">
+			copyright = <"copyright (c) 2009 openEHR Foundation">
+		>
+	>
+	lifecycle_state = <"Initial">
+	other_contributors = <"Marja Buur, Medisch Centrum Alkmaar, Netherlands", "Rong Chen, Cambio Healthcare Systems, Sweden", "Angela de Zwart, Orion Health, New Zealand", "Paul Donaldson, Nursing Informatics Australia, Australia", "Sebastian Garde, Ocean Informatics, Germany", "Heather Grain, Llewelyn Grain Informatics, Australia", "Anne Harbison, CPCER, Australia", "Sam Heard, Ocean Informatics, Australia", "Andrew James, University of Toronto, Canada", "Shinji Kobayashi, Ehime University, Japan", "Heather Leslie, Ocean Informatics, Australia (Editor)", "Rikard Lovstrom, Swedish Medical Association, Sweden", "Ian McNicoll, Ocean Informatics, United Kingdom", "Jeroen Meintjens, Medisch Centrum Alkmaar, Netherlands", "Arturo Romero, SESCAM, Spain", "Soon Ghee Yap, Singapore Health Services Pte Ltd, Singapore">
+	other_details = <
+		["MD5-CAM-1.0.1"] = <"1605E211E9BFB4093A72CCE7A9792FF9">
+		["references"] = <"Clinical Guidelines on the Identification, Evaluation, and Treatment of Overweight and Obesity in Adults: The Evidence Report [Internet]. Bethesda (MD): National Heart, Lung, and Blood Institute; NIH Publication No. 98-4083, Sep 1998, [cited 2009 July 02]. Available from: http://www.nhlbi.nih.gov/guidelines/obesity/
+
+About BMI for Children and Teens [Internet]. Atlanta (GA): Division of Nutrition, Physical Activity and Obesity, Centers for Disease Control and Prevention; 2009 Jan 27 [cited 2009 Jul 28 ]. Available from: http://www.cdc.gov/healthyweight/assessing/bmi/childrens_BMI/about_childrens_BMI.html
+
+WHO Child Growth Standards: Length/height-for-age, weight-for-age, weight-for-length, weight-for-height and body mass index-for-age: Methods and development. [Internet] Geneva, Switzerland: WHO Multicentre Growth Reference Study Group, World Health Organization; 2006 [cited 2009 July 02].  Chapter 6, BMI-for-age standards. Available from: http://www.who.int/childgrowth/standards/Chap_6.pdf.
+
+Obesity: Preventing and Managing the Global Epidemic: Report of a WHO Consultation [Internet]. Geneva, Switzerland: World Health Organisation; 2000 [cited 2009 Jul 28]. Available from: http://www.who.int/nutrition/publications/obesity/WHO_TRS_894/en/index.html
+
+Tzamaloukas AH, Patron A, Malhotra D. Body Mass Index in Amputees. Journal of Parenteral and Enteral Nutrition [Internet]. 1994 [cited 2009 Jul 28]; 18 (4): 355. Available from: http://pen.sagepub.com/cgi/content/abstract/18/4/355">
+       >
+
+definition
+	OBSERVATION[at0000] matches {	-- Body mass index
+		data matches {
+			HISTORY[at0001] matches {	-- history
+				events cardinality matches {1..*; unordered} matches {
+					EVENT[at0002] occurrences matches {1..*} matches {	-- Any event
+						data matches {
+							ITEM_TREE[at0003] matches {	-- Single
+								items cardinality matches {1..*; unordered} matches {
+									ELEMENT[at0004] matches {	-- Body Mass Index
+										value matches {
+											C_DV_QUANTITY <
+												property = <[openehr::349]>
+												list = <
+													["1"] = <
+														units = <"kg/m2">
+														magnitude = <|0.0..<1000.0|>
+														precision = <|1|>
+													>
+													["2"] = <
+														units = <"lb/in2">
+														magnitude = <|0.0..<1000.0|>
+														precision = <|1|>
+													>
+												>
+											>
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		protocol matches {
+			ITEM_LIST[at0005] matches {	-- List
+				items cardinality matches {0..*; ordered} matches {
+					ELEMENT[at0006] occurrences matches {0..1} matches {	-- Method
+						value matches {
+							DV_CODED_TEXT matches {
+								defining_code matches {
+									[local::
+									at0007, 	-- Automatic entry
+									at0008]	-- Direct entry
+								}
+							}
+						}
+					}
+					ELEMENT[at0010] occurrences matches {0..1} matches {	-- Formula
+						value matches {
+							DV_TEXT matches {*}
+						}
+					}
+					ELEMENT[at0011] occurrences matches {0..1} matches {	-- Comment
+						value matches {
+							DV_TEXT matches {*}
+						}
+					}
+				}
+			}
+		}
+	}
+
+
+ontology
+	term_definitions = <
+		["en"] = <
+			items = <
+				["at0000"] = <
+					text = <"Body mass index">
+					description = <"Calculated measurement which compares a person's weight and height.">
+				>
+				["at0001"] = <
+					text = <"history">
+					description = <"@ internal @">
+				>
+				["at0002"] = <
+					text = <"Any event">
+					description = <"Any timed recording of Body Mass Index.">
+				>
+				["at0003"] = <
+					text = <"Single">
+					description = <"@ internal @">
+				>
+				["at0004"] = <
+					text = <"Body Mass Index">
+					description = <"Index describing ratio of weight to height.">
+				>
+				["at0005"] = <
+					text = <"List">
+					description = <"@ internal @">
+				>
+				["at0006"] = <
+					text = <"Method">
+					description = <"The method of entering the Body Mass Index.">
+				>
+				["at0007"] = <
+					text = <"Automatic entry">
+					description = <"Body Mass Index calculated and entered automatically without user intervention.">
+				>
+				["at0008"] = <
+					text = <"Direct entry">
+					description = <"Body Mass Index calculated and entered directly by user.">
+				>
+				["at0010"] = <
+					text = <"Formula">
+					description = <"Formula used to derive the Body Mass Index.">
+				>
+				["at0011"] = <
+					text = <"Comment">
+					description = <"Comment about the Body Mass Index measurement eg noting that the measurements used were adjusted weight/height.">
+				>
+			>
+		>
+	>
Index: by/branches/0.5/lib/adl_parser/test/dparser_test.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/dparser_test.rb	(revision 289)
+++ 	(revision )
@@ -1,22 +1,0 @@
-#$:.unshift File.join(File.dirname(__FILE__))
-
-require 'lib/dparser.rb'
-require 'test/unit'
-
-class DADLParserTest < Test::Unit::TestCase
-  def setup
-    @parser = ::OpenEHR::DADLParser.new
-  end
-
-  def test_init
-    assert_instance_of ::OpenEHR::DADLParser,@parser
-  end
-
-  def test_parse
-    dadl_line_break = File.read('tests/dadl_line_break.dadl')
-    assert_nothing_raised do
-      @parser.parse(dadl_line_break, 'dadl_line_break')
-    end
-  end
-
-end
Index: /ruby/branches/0.5/lib/adl_parser/test/parser_test.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/parser_test.rb	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/test/parser_test.rb	(revision 290)
@@ -1,5 +1,3 @@
-#require 'lib/parser.rb'
-require 'lib/adl_parser.rb'
-require 'test/unit'
+require File.dirname(__FILE__) + '/test_helper.rb'
 
 class ADLParserTest < Test::Unit::TestCase
@@ -8,145 +6,228 @@
   end
 
-  def test_init
+  must "assert parser instance" do
     assert_instance_of ::OpenEHR::ADL::Parser,@parser
   end
 
-  def test_parse
-    laboratory_request = File.read('test/adl/openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl')
-    assert_nothing_raised do
-      result = @parser.parse(laboratory_request, 'openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl')
-      assert_instance_of OpenEhr::AM::Archetype::ARCHETYPE, result
-      assert_instance_of OpenEhr::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, result.description
-      assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, result.definition
-#      assert_equal '', result.definition
-    end
-
-    apgar = File.read('test/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl')
-    assert_nothing_raised do
-      result = @parser.parse(apgar, 'openEHR-EHR-OBSERVATION.apgar.v1.adl')
-      assert_instance_of OpenEhr::AM::Archetype::ARCHETYPE, result
-      assert_instance_of OpenEhr::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, result.description
-      assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, result.definition
-    end
-
-    evaluation = File.read('test/adl/openEHR-EHR-EVALUATION.adverse.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(evaluation, 'openEHR-EHR-EVALUATION.adverse.v1.adl')
-    end
-
-
-
-    referral = File.read('test/adl/openEHR-EHR-ITEM_TREE.referral.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(referral, 'openEHR-EHR-ITEM_TREE.referral.v1.adl')
-    end
-
-    exam_fetus = File.read('test/adl/openEHR-EHR-CLUSTER.exam-fetus.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_fetus, 'openEHR-EHR-CLUSTER.exam-fetus.v1.adl')
-    end
-
-    exam_uterine_cervix = File.read('test/adl/openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_uterine_cervix, 'openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl')
-    end
-
-    imaging = File.read('test/adl/openEHR-EHR-ACTION.imaging.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(imaging, 'openEHR-EHR-ACTION.imaging.v1.adl')
-    end
-
-    exam_nervous_system = File.read('test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_nervous_system, 'openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')
-    end
-    exam_generic = File.read('test/adl/openEHR-EHR-CLUSTER.exam-generic.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_generic, 'openEHR-EHR-CLUSTER.exam-generic.v1.adl')
-    end
-    exam_generic_mass = File.read('test/adl/openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_generic_mass, 'openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl')
-    end
-    exam_generic_lymphnode = File.read('test/adl/openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_generic_lymphnode, 'openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl')
-    end
-    exam_generic_joint = File.read('test/adl/openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_generic_joint, 'openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl')
-    end
-    exam_chest = File.read('test/adl/openEHR-EHR-CLUSTER.exam-chest.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_chest, 'openEHR-EHR-CLUSTER.exam-chest.v1.adl')
-    end
-    exam_abdomen = File.read('test/adl/openEHR-EHR-CLUSTER.exam-abdomen.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(exam_abdomen, 'openEHR-EHR-CLUSTER.exam-abdomen.v1.adl')
-    end
-    cluster_auscultation = File.read('test/adl/openEHR-EHR-CLUSTER.auscultation.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(cluster_auscultation, 'openEHR-EHR-CLUSTER.auscultation.v1.adl')
-    end
-    cluster_auscultation_chest = File.read('test/adl/openEHR-EHR-CLUSTER.auscultation-chest.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(cluster_auscultation_chest, 'openEHR-EHR-CLUSTER.auscultation-chest.v1.adl')
-    end
-    vital_signs = File.read('test/adl/openEHR-EHR-SECTION.vital_signs.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(vital_signs, 'openEHR-EHR-SECTION.vital_signs.v1')
-    end
-    summary = File.read('test/adl/openEHR-EHR-SECTION.summary.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(summary, 'openEHR-EHR-SECTION.summary.v1.adl')
-    end
-
-    findings = File.read('test/adl/openEHR-EHR-SECTION.findings.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(findings, 'openEHR-EHR-SECTION.findings.v1.adl')
-    end
-
-    reason_for_encounter = File.read('test/adl/openEHR-EHR-SECTION.reason_for_encounter.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(reason_for_encounter, 'openEHR-EHR-SECTION.reason_for_encounter.v1.adl')
-    end
-
-    imaging = File.read('test/adl/openEHR-EHR-ITEM_TREE.imaging.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(imaging, 'openEHR-EHR-ITEM_TREE.imaging.v1.adl')
-    end
-    instruction_referral = File.read('test/adl/openEHR-EHR-INSTRUCTION.referral.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(instruction_referral, 'openEHR-EHR-INSTRUCTION.referral.v1.adl')
-    end
-    instruction_medication = File.read('test/adl/openEHR-EHR-INSTRUCTION.medication.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(instruction_medication, 'openEHR-EHR-INSTRUCTION.medication.v1.adl')
-    end
-    action_referral = File.read('test/adl/openEHR-EHR-ACTION.referral.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(action_referral, 'openEHR-EHR-ACTION.referral.v1.adl')
-    end
-
-    dimensions_circumference = File.read('test/adl/openEHR-EHR-CLUSTER.dimensions.v1.adl')
-    assert_nothing_raised do
-      @parser.parse(dimensions_circumference, 'openEHR-EHR-CLUSTER.dimensions.v1.adl')
-    end
-
-    discharge = File.read('test/adl/openEHR-EHR-COMPOSITION.discharge.v1draft.adl')
-    assert_nothing_raised do
-      @parser.parse(discharge, 'openEHR-EHR-COMPOSITION.discharge.v1draft.adl')
-    end
-
-    encounter = File.read('test/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl')
-    assert_nothing_raised do
-      @parser.parse(encounter, 'openEHR-EHR-COMPOSITION.encounter.v1draft.adl')
-    end
-
-
-#     medication = File.read('test/adl/openEHR-EHR-ITEM_TREE.medication.v1.adl')
-#     assert_nothing_raised do
-#       @parser.parse(medication, 'openEHR-EHR-ITEM_TREE.medication.v1.adl')
-#     end
-  end
+  must "test_archetype_id.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/test_archetype_id.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-SECTION.summary.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-ACTION.imaging.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ACTION.imaging.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-ACTION.imaging.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-ACTION.referral.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ACTION.referral.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-ACTION.referral.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.auscultation-chest.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.auscultation-chest.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.auscultation-chest.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.auscultation.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.auscultation.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.auscultation.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+
+  must "openEHR-EHR-CLUSTER.exam-abdomen.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-abdomen.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-abdomen.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-chest.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-chest.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-chest.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-generic-joint.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-generic-mass.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-generic.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-generic.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-nervous_system.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-COMPOSITION.discharge.v1draft.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-COMPOSITION.discharge.v1draft.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-COMPOSITION.discharge.v1draft')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-COMPOSITION.encounter.v1draft.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-COMPOSITION.encounter.v1draft')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-INSTRUCTION.medication.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-INSTRUCTION.medication.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-INSTRUCTION.medication.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-INSTRUCTION.referral.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-INSTRUCTION.referral.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-INSTRUCTION.referral.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-ITEM_TREE.Laboratory_request.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+
+  must "openEHR-EHR-OBSERVATION.apgar.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-OBSERVATION.apgar.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-SECTION.findings.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.findings.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-SECTION.findings.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+  must "openEHR-EHR-SECTION.reason_for_encounter.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.reason_for_encounter.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-SECTION.reason_for_encounter.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+
+  must "openEHR-EHR-SECTION.vital_signs.v1.adl be properly parsed" do
+    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.vital_signs.v1.adl")
+    assert_nothing_raised do
+      ast = @parser.parse(file, 'openEHR-EHR-SECTION.vital_signs.v1')
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+    end
+  end
+
+
+# C_DV_QUANTITY parse error
+#   must "openEHR-EHR-CLUSTER.dimensions-circumference.v1.adl be properly parsed" do
+#     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.dimensions-circumference.v1.adl")
+#     assert_nothing_raised do
+#       ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.dimensions-circumference.v1')
+#       assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+#     end
+#   end
+
+#   must "openEHR-EHR-CLUSTER.dimensions.v1.adl be properly parsed" do
+#     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.dimensions.v1.adl")
+#     assert_nothing_raised do
+#       ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.dimensions.v1')
+#       assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+#     end
+#   end
+
+#   must "openEHR-EHR-CLUSTER.exam-fetus.v1.adl be properly parsed" do
+#     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-fetus.v1.adl")
+#     assert_nothing_raised do
+#       ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-fetus.v1')
+#       assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+#     end
+#   end
+
+#   must "openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl be properly parsed" do
+#     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl")
+#     assert_nothing_raised do
+#       ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-uterine_cervix.v1')
+#       assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+#     end
+#   end
+
+#   must "openEHR-EHR-EVALUATION.adverse.v1.adl be properly parsed" do
+#     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-EVALUATION.adverse.v1.adl")
+#     assert_nothing_raised do
+#       ast = @parser.parse(file, 'openEHR-EHR-EVALUATION.adverse.v1')
+#       assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+#     end
+#   end
+#   must "openEHR-EHR-OBSERVATION.body_mass_index.v1.adl be properly parsed" do
+#     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl")
+#     assert_nothing_raised do
+#       ast = @parser.parse(file, 'openEHR-EHR-OBSERVATION.body_mass_index.v1')
+#       assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id
+#     end
+#   end
+
+
 end
Index: /ruby/branches/0.5/lib/adl_parser/test/scanner_test.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/scanner_test.rb	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/test/scanner_test.rb	(revision 290)
@@ -1,113 +1,105 @@
-require 'lib/adl_parser.rb'
-#require 'lib/scanner.rb'
-require 'test/unit'
+require File.dirname(__FILE__) + '/test_helper.rb'
 
-class YaparcParserTest < Test::Unit::TestCase
-  def test_RootScanner
-    parser = OpenEhr::ADL::Scanner::DADL::RootScanner.new
-    assert_instance_of OpenEhr::ADL::Scanner::DADL::RootScanner,parser
-    result = parser.parse('')
+class ADLScannerTest < Test::Unit::TestCase
+  def setup
+    @scanner = OpenEHR::ADL::Scanner::ADLScanner.new([:adl], "filename")
   end
 
-  def test_V_LOCAL_TERM_CODE_REF
-    parser = OpenEhr::ADL::Scanner::Common::V_LOCAL_TERM_CODE_REF.new
-    assert_instance_of OpenEhr::ADL::Scanner::Common::V_LOCAL_TERM_CODE_REF,parser
-    result = parser.parse('[en-us]')
-    assert_instance_of Yaparc::Result::OK, result
+  must "assert OpenEHR::ADL::Scanner::ADLScanner scanner instance" do
+    assert_instance_of OpenEHR::ADL::Scanner::ADLScanner, @scanner
   end
 
-  def test_V_QUALIFIED_TERM_CODE_REF
-    parser = OpenEhr::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF.new
-    assert_instance_of OpenEhr::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF,parser
-    result = parser.parse('[ISO_639::en]')
-    assert_instance_of Yaparc::Result::OK, result
-    result = parser.parse('[ISO_639::en-us]')
-    assert_instance_of Yaparc::Result::OK, result
+  must "assert ADLScanner scanner scan CR and lineno incremented" do
+    lineno = @scanner.lineno
+    @scanner.scan("\n")
+    assert_equal lineno+1, @scanner.lineno
   end
 
-  def test_V_STRING
-    parser = OpenEhr::ADL::Scanner::Common::V_STRING.new
-    assert_instance_of OpenEhr::ADL::Scanner::Common::V_STRING,parser
-    result = parser.parse('"this is a string"')
-    assert_instance_of Yaparc::Result::OK, result
-    result = parser.parse('"en-us"')
-    assert_instance_of Yaparc::Result::OK, result
+  must "assert ADLScanner scanner scan ARCHETYPE_ID" do
+    lineno = @scanner.lineno
+    @scanner.scan("openEHR-EHR-OBSERVATION.body_mass_index.v1") do |sym, val|
+      assert_equal :V_ARCHETYPE_ID,sym
+      assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID,val
+    end
   end
 
-  def test_V_REAL
-    parser = OpenEhr::ADL::Scanner::Common::V_REAL.new
-    assert_instance_of OpenEhr::ADL::Scanner::Common::V_REAL,parser
-    result = parser.parse('0.1')
-    assert_instance_of Yaparc::Result::OK, result
-    result = parser.parse('0.0..20000.0')
-    assert_instance_of Yaparc::Result::OK, result
-    assert_equal [:V_REAL, "0.0"], result.value
-    assert_equal "..20000.0", result.input
+  must "assert ADLScanner scanner scan white space and lineno unchanged" do
+    lineno = @scanner.lineno
+    @scanner.scan(" ")
+    assert_equal lineno, @scanner.lineno
   end
 
-  def test_V_ISO8601_DURATION
-    parser = OpenEhr::ADL::Scanner::Common::V_ISO8601_DURATION.new
-    assert_instance_of OpenEhr::ADL::Scanner::Common::V_ISO8601_DURATION,parser
-    result = parser.parse('PT1M')
-    assert_instance_of Yaparc::Result::OK, result
-    result = parser.parse('PYMWDTHMS')
-    assert_instance_of Yaparc::Result::OK, result
-    assert_equal [:V_ISO8601_DURATION, "PYMWDTHMS"], result.value
+  must "assert ADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do
+    @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val|
+      assert_equal :V_QUALIFIED_TERM_CODE_REF,sym
+      assert_equal "ICD10AM(1998)::F23",val
+    end
+  end
+end
+
+class CADLScannerTest < Test::Unit::TestCase
+  def setup
+    @scanner = OpenEHR::ADL::Scanner::CADLScanner.new([:cadl], "filename")
   end
 
-  def test_V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN
-    parser = OpenEhr::ADL::Scanner::CADL::V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN.new
-    assert_instance_of OpenEhr::ADL::Scanner::CADL::V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN,parser
-    result = parser.parse('yyyy-??-??T??:??:??')
-    assert_instance_of Yaparc::Result::OK, result
+  must "assert OpenEHR::ADL::Scanner::CADLScanner scanner instance" do
+    assert_instance_of OpenEHR::ADL::Scanner::CADLScanner, @scanner
   end
 
-  def test_V_ISO8601_DATE_CONSTRAINT_PATTERN
-    parser = OpenEhr::ADL::Scanner::CADL::V_ISO8601_DATE_CONSTRAINT_PATTERN.new
-    assert_instance_of OpenEhr::ADL::Scanner::CADL::V_ISO8601_DATE_CONSTRAINT_PATTERN,parser
-    result = parser.parse('yyyy-mm-XX-dd')
-    assert_instance_of Yaparc::Result::OK, result
+  must "assert CADLScanner scanner scan V_ATTRIBUTE_IDENTIFIER" do
+    lineno = @scanner.lineno
+    @scanner.scan("identifier") do |sym, val|
+      assert_equal :V_ATTRIBUTE_IDENTIFIER, sym
+      assert_equal "identifier", val
+    end
+    assert_equal lineno, @scanner.lineno
   end
 
-  def test_V_ISO8601_TIME_CONSTRAINT_PATTERN
-    parser = OpenEhr::ADL::Scanner::CADL::V_ISO8601_TIME_CONSTRAINT_PATTERN.new
-    assert_instance_of OpenEhr::ADL::Scanner::CADL::V_ISO8601_TIME_CONSTRAINT_PATTERN,parser
-    result = parser.parse('hh:mm:ss:??')
-    assert_instance_of Yaparc::Result::OK, result
+  must "assert CADLScanner scanner scan reserved words" do
+    lineno = @scanner.lineno
+    @scanner.scan("then") do |sym, val|
+      assert_equal :SYM_THEN, sym
+    end
   end
 
-  def test_dadl_reserved
-    parser = OpenEhr::ADL::Scanner::DADL::RootScanner.new
-    result = parser.parse('then')
-    assert_instance_of Yaparc::Result::OK, result
-    result = parser.parse('infinity')
-    assert_instance_of Yaparc::Result::OK, result
-    assert_equal [:SYM_INFINITY, :SYM_INFINITY], result.value
+  must "assert CADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do
+    @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val|
+      assert_equal :V_QUALIFIED_TERM_CODE_REF,sym
+      assert_equal "ICD10AM(1998)::F23",val
+    end
   end
 
-  def test_cadl
-    parser = OpenEhr::ADL::Scanner::CADL::RootScanner.new
-    assert_instance_of OpenEhr::ADL::Scanner::CADL::RootScanner,parser
-    result = parser.parse('PT1M')
-    assert_instance_of Yaparc::Result::OK, result
-    assert_equal [:V_ISO8601_DURATION, "PT1M"], result.value
-    result = parser.parse('PYMWDTHMS')
-    assert_instance_of Yaparc::Result::OK, result
-    assert_equal [:V_ISO8601_DURATION, "PYMWDTHMS"], result.value
+  must "assert CADLScanner scanner scan V_ISO8601_DURATION" do
+    @scanner.scan("PT1M") do |sym, val|
+      assert_equal :V_ISO8601_DURATION,sym
+      assert_equal "PT1M",val
+    end
+  end
+end
+
+class DADLScannerTest < Test::Unit::TestCase
+  def setup
+    @scanner = OpenEHR::ADL::Scanner::DADLScanner.new([:dadl], "filename")
   end
 
-  def test_cadl_reserved
-    parser = OpenEhr::ADL::Scanner::CADL::RootScanner.new
-    result = parser.parse('then')
-    assert_instance_of Yaparc::Result::OK, result
-    result = parser.parse('cardinality')
-    assert_instance_of Yaparc::Result::OK, result
-    assert_equal [:SYM_CARDINALITY, :SYM_CARDINALITY], result.value
-    result = parser.parse('ordered')
-    assert_instance_of Yaparc::Result::OK, result
-    assert_equal "", result.input
-    assert_equal [:SYM_ORDERED, :SYM_ORDERED], result.value
+  must "assert DADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do
+    @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val|
+      assert_equal :V_QUALIFIED_TERM_CODE_REF,sym
+      assert_equal "ICD10AM(1998)::F23",val
+    end
   end
 
-  
+  must "assert DADLScanner scanner scan V_ISO8601_EXTENDED_DATE" do
+    @scanner.scan("2005-10-10") do |sym, val|
+      assert_equal :V_ISO8601_EXTENDED_DATE,sym
+      assert_equal "2005-10-10",val
+    end
+  end
+
+  must "assert DADLScanner scanner scan V_STRING" do
+    @scanner.scan("\"string\"") do |sym, val|
+      assert_equal :V_STRING,sym
+      assert_equal "string",val
+    end
+  end
 end
Index: /ruby/branches/0.5/lib/adl_parser/test/semantic_test.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/semantic_test.rb	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/test/semantic_test.rb	(revision 290)
@@ -1,4 +1,3 @@
-require 'lib/adl_parser.rb'
-require 'test/unit'
+require File.dirname(__FILE__) + '/test_helper.rb'
 
 class ADLSemanticTest < Test::Unit::TestCase
@@ -7,5 +6,5 @@
   end
 
-  def test_init
+  must "assert adl parser instance" do
     assert_instance_of ::OpenEHR::ADL::Parser,@parser
   end
Index: /ruby/branches/0.5/lib/adl_parser/test/shell_test.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/shell_test.rb	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/test/shell_test.rb	(revision 290)
@@ -1,4 +1,3 @@
-require 'lib/adl_parser.rb'
-require 'test/unit'
+require File.dirname(__FILE__) + '/test_helper.rb'
 
 class ShellADLValidatorTest < Test::Unit::TestCase
@@ -7,19 +6,19 @@
   end
 
-  def test_init
+  must "assert application validator instance" do
     assert_instance_of ::OpenEHR::Application::ADLValidator,@adl_validator
   end
 
-  def test_run
+
+  must "validating openEHR-EHR-CLUSTER.exam-nervous_system.v1 using File.open not raised" do
     assert_nothing_raised do
-      adl_file = File.open('test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')
+      adl_file = File.open("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl")
       @adl_validator.run(adl_file)
     end
+  end
+
+  must "validating openEHR-EHR-CLUSTER.exam-nervous_system.v1 using File.read not raised" do
     assert_nothing_raised do
-      adl_string = File.open('test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')
-      @adl_validator.run(adl_string)
-    end
-    assert_nothing_raised do
-      adl_string = File.read('test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')
+      adl_string = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl")
       stringio = StringIO.new(adl_string)
       @adl_validator.run(stringio)
Index: /ruby/branches/0.5/lib/adl_parser/test/test_helper.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/test_helper.rb	(revision 290)
+++ /ruby/branches/0.5/lib/adl_parser/test/test_helper.rb	(revision 290)
@@ -0,0 +1,28 @@
+require 'test/unit'
+
+TEST_ROOT_DIR = File.dirname(__FILE__)
+$LOAD_PATH << File.join(TEST_ROOT_DIR, '..', 'lib')
+require "rubygems"
+require 'adl_parser.rb'
+require 'adl_scanner.rb'
+require 'rm.rb'
+require 'am.rb'
+
+
+# c.f. "Ruby Best Practice",p.75
+module Test::Unit
+  class TestCase
+    def self.must(name, &block)
+      test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
+      defined = instance_method(test_name) rescue false
+      raise "#{test_name} is already defined in #{self}" if defined
+      if block_given?
+        define_method(test_name, &block)
+      else
+        define_method(test_name) do
+          flunk "No implementation provided for #{name}"
+        end
+      end
+    end
+  end
+end
Index: /ruby/branches/0.5/lib/adl_parser/test/validator_test.rb
===================================================================
--- /ruby/branches/0.5/lib/adl_parser/test/validator_test.rb	(revision 289)
+++ /ruby/branches/0.5/lib/adl_parser/test/validator_test.rb	(revision 290)
@@ -1,4 +1,4 @@
-require 'lib/adl_parser.rb'
-require 'test/unit'
+require File.dirname(__FILE__) + '/test_helper.rb'
+
 
 class ADLValidatorTest < Test::Unit::TestCase
@@ -7,19 +7,17 @@
   end
 
-  def test_init
+  must "assert adl validator instance" do
     assert_instance_of ::OpenEHR::ADL::Validator,@validator
   end
 
-  def test_validate
-    exam_nervous_system = File.read('test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')
+  must "assert validation openEHR-EHR-CLUSTER.exam-nervous_system.v1" do
+    exam_nervous_system = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl")
     assert_nothing_raised do
-      @validator.validate(exam_nervous_system, 'openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')
+      @validator.validate(exam_nervous_system, 'openEHR-EHR-CLUSTER.exam-nervous_system.v1')
     end
-
+  end
 #     exam_uterine_cervix = File.read('tests/openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl')
 # #    assert_raise(Racc::ParseError) do
 #    @validator.validate(exam_uterine_cervix, 'openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl')
 # #    end
-
-  end
 end
Index: /ruby/branches/0.5/lib/models/Rakefile
===================================================================
--- /ruby/branches/0.5/lib/models/Rakefile	(revision 289)
+++ /ruby/branches/0.5/lib/models/Rakefile	(revision 290)
@@ -41,4 +41,5 @@
   s.email = 'openehr-jp@openehr.jp'
   s.test_files = FileList['tests/test_*.rb', '*.adl']
+
   candidates = Dir.glob("{am,rm,docs,tests}/**/*") + FileList['COPYING', 'Rakefile','am.rb','assumed_library_types.rb','rm.rb']
   s.files = candidates.delete_if do |item|
