Index: ruby/trunk/lib/adl_parser/Rakefile
===================================================================
--- ruby/trunk/lib/adl_parser/Rakefile	(revision 258)
+++ ruby/trunk/lib/adl_parser/Rakefile	(revision 261)
@@ -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."
@@ -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']
@@ -92,5 +89,5 @@
   s.extra_rdoc_files = ["README"]
   s.add_dependency("yaparc", ">= 0.2.3")
-  s.add_dependency("openehr_models", ">= 0.0.1")
+  s.add_dependency("openehr_models", ">= 0.0.3")
 end
 
@@ -105,6 +102,4 @@
 
 
-
-
 ### Local Variables:
 ### mode:ruby
Index: ruby/trunk/lib/adl_parser/lib/adl_parser.rb
===================================================================
--- ruby/trunk/lib/adl_parser/lib/adl_parser.rb	(revision 258)
+++ ruby/trunk/lib/adl_parser/lib/adl_parser.rb	(revision 261)
@@ -8,4 +8,5 @@
 $:.unshift File.join(File.dirname(__FILE__))
 require 'logger'
+require 'adl_scanner.rb'
 
 module OpenEHR
@@ -18,6 +19,4 @@
     LOG.level = Logger::WARN
   end
-  
-  
 
 
@@ -25,8 +24,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/trunk/lib/adl_parser/lib/adl_scanner.rb
===================================================================
--- ruby/trunk/lib/adl_parser/lib/adl_scanner.rb	(revision 261)
+++ ruby/trunk/lib/adl_parser/lib/adl_scanner.rb	(revision 261)
@@ -0,0 +1,343 @@
+require 'rubygems'
+gem 'yaparc'
+require 'yaparc'
+
+
+module OpenEHR
+  module ADL
+    module Scanner
+      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
+
+=begin <CADL::Reserved class>
+=end
+        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
+    end
+  end
+end
Index: ruby/trunk/lib/adl_parser/lib/parser.rb
===================================================================
--- ruby/trunk/lib/adl_parser/lib/parser.rb	(revision 258)
+++ ruby/trunk/lib/adl_parser/lib/parser.rb	(revision 261)
@@ -24,5 +24,5 @@
     class Parser < Racc::Parser
 
-module_eval(<<'...end parser.y/module_eval...', 'parser.y', 1188)
+module_eval(<<'...end parser.y/module_eval...', 'parser.y', 1206)
 
 def assert_at(file,line, message = "")
@@ -33,9 +33,9 @@
 
 if $DEBUG
-  @@log = Logger.new('log/parser.log','daily')
-  @@log.level = Logger::INFO
+  @@logger = Logger.new('log/parser.log','daily')
+  @@logger.level = Logger::INFO
 else
-  @@log = Logger.new(STDOUT)
-  @@log.level = Logger::WARN
+  @@logger = Logger.new(STDOUT)
+  @@logger.level = Logger::WARN
 end
 
@@ -102,4 +102,5 @@
 
 def scan
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan at #{@filename}:#{@lineno}:")
   until @data.nil?  do
     case @adl_type.last
@@ -120,4 +121,9 @@
         yield sym, val
       end
+    when :term_constraint
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+      @data = scan_term_constraint(@data) do |sym, val|
+        yield sym, val
+      end
     else
       raise
@@ -130,8 +136,8 @@
 
 def scan_adl(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_adl at #{@filename}:#{@lineno}: data = #{data.inspect}")
   until data.nil?  do
     case @adl_type.last
     when :adl
-#      puts "Entering scan_adl"
       case data
       when /\A\n/ # carriage return
@@ -142,5 +148,5 @@
       when /\A--.*\n/ # single line comment
         @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
         ;
       when /\Adescription/   # description
@@ -148,10 +154,9 @@
       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
-      when /\A(\w+)-(\w+)-(\w+)\.(\w+)(-\w+)?\.(v[0-9]+)/   #V_ARCHETYPE_ID
+      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)
@@ -162,8 +167,8 @@
         word = $&
         if @@adl_reserved[word]
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: @@adl_reserved = #{@@adl_reserved[word]} at #{@filename}:#{@lineno}")
+          @@logger.debug("#{__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}")
+          @@logger.debug("#{__FILE__}:#{__LINE__}: scan_adl: V_ATTRIBUTE_IDENTIFIER = #{$&} at #{@filename}:#{@lineno}")
           yield :V_ATTRIBUTE_IDENTIFIER, $&
         end
@@ -188,5 +193,4 @@
         else
           adl_type = @adl_type.pop
-#          puts "Escaping #{adl_type}"
           assert_at(__FILE__,__LINE__){adl_type == :dadl}
           yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
@@ -194,5 +198,5 @@
       when /\A\{/   # {
         @adl_type.push(:cadl)
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
         yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
       when /\A\}/   # }
@@ -200,5 +204,5 @@
 #        puts "Escaping #{adl_type}"
         assert_at(__FILE__,__LINE__){adl_type == :cadl}
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
         yield :SYM_END_CBLOCK, $&
       when /\A\-/   # -
@@ -285,20 +289,18 @@
       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"
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan_adl: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+
       data = scan_term_constraint(data) do |sym, val|
         yield sym, val
@@ -312,8 +314,8 @@
 
 def scan_cadl(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_cadl at #{@filename}:#{@lineno}: data = #{data.inspect}")
   until data.nil?  do
     case @adl_type.last
     when :cadl
-#      puts "Entering scan_cadl"
       case scanned = @@cadl_scanner.parse(data)
       when Yaparc::Result::OK
@@ -336,5 +338,5 @@
       when /\A--.*\n/ # single line comment
         @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
         ;
         ###----------/* symbols */ ------------------------------------------------- 
@@ -404,5 +406,5 @@
       when /\A\{/   # {
         @adl_type.push(:cadl)
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
         yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
       when /\A\}/   # }
@@ -410,5 +412,5 @@
 #        puts "Escaping #{adl_type}"
         assert_at(__FILE__,__LINE__){adl_type == :cadl}
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
         yield :SYM_END_CBLOCK, :SYM_END_CBLOCK
       when /\A\$/   # $
@@ -419,5 +421,5 @@
         yield :Question_mark_code, :Question_mark_code
       when /\A\|/   # |
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
         if @in_interval
           @in_interval = false
@@ -426,16 +428,15 @@
           @in_interval = true
         end
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__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]
+      when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/  #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
+#      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]*/
+      when /\A\[([a-zA-Z0-9\(\)\._\-]+)::[ \t\n]*/
         @adl_type.push(:term_constraint)
-        yield :START_TERM_CODE_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, $&
@@ -457,5 +458,5 @@
           yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]
         else
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}:#{@lineno}")
+          @@logger.debug("#{__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
@@ -493,20 +494,18 @@
       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"
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+      
       data = scan_term_constraint(data) do |sym, val|
         yield sym, val
@@ -519,8 +518,8 @@
 
 def scan_dadl(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_dadl at #{@filename}:#{@lineno}: data = #{data.inspect}")
   until data.nil?  do
     case @adl_type.last
     when :dadl
-#      puts "Entering scan_dadl"
       case scanned = @@dadl_scanner.parse(data)
       when Yaparc::Result::OK
@@ -538,5 +537,5 @@
       when /\A--.*\n/ # single line comment
         @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
         ;
         ###----------/* symbols */ ------------------------------------------------- 
@@ -569,5 +568,4 @@
         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, $&
@@ -610,5 +608,5 @@
         yield :Question_mark_code, :Question_mark_code
       when /\A\|/   # |
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
         if @in_interval
           @in_interval = false
@@ -617,5 +615,5 @@
           @in_interval = true
         end
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__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]
@@ -666,10 +664,8 @@
       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
@@ -681,5 +677,6 @@
       end
     when :term_constraint
-#      puts "Entering scan_term_constraint"
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan_dadl: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+
       data = scan_term_constraint(data) do |sym, val|
         yield sym, val
@@ -692,8 +689,8 @@
 
 def scan_regexp(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_regexp at #{@filename}:#{@lineno}: data = #{data.inspect}")
   until data.nil?  do
     case @adl_type.last
     when :regexp
-#      puts "Entering scan_regexp"
       case data
       when /\A\/\}/ #V_REGEXP
@@ -719,20 +716,17 @@
       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"
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan_regexp: Entering scan_term_constraint at #{@filename}:#{@lineno}")
       data = scan_term_constraint(data) do |sym, val|
         yield sym, val
@@ -745,8 +739,8 @@
 
 def scan_term_constraint(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_term_constraint")
   until data.nil?  do
     case @adl_type.last
     when :term_constraint
-#      puts "Entering scan_term_constraint"
       case data
       when /\A\n/ # carriage return
@@ -757,15 +751,14 @@
       when /\A--.*$/ # single line comment
         @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_term_constraint: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+        #@@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, $&
-      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 ']'
+      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, $&
+        yield :END_TERM_CODE_CONSTRAINT, $1
       else
         raise "data = #{data}"
@@ -773,15 +766,12 @@
       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
@@ -1132,6 +1122,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,
@@ -1341,13 +1331,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,
@@ -1656,17 +1646,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,
@@ -1917,5 +1907,4 @@
   "c_attributes",
   "c_object",
-  "v_c_domain_type",
   "archetype_internal_ref",
   "archetype_slot",
@@ -1924,4 +1913,5 @@
   "c_ordinal",
   "c_primitive_object",
+  "v_c_domain_type",
   "absolute_path",
   "c_archetype_slot_head",
@@ -2059,5 +2049,5 @@
       archetype.original_language = language
     end
-    @@log.info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
     result = archetype
   
@@ -2203,5 +2193,5 @@
   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]
   
@@ -2276,23 +2266,15 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 210)
+module_eval(<<'.,.,', 'parser.y', 220)
   def _reduce_35(val, _values, result)
-        result = val[0]
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 214)
+        @@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', 219)
-  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]
@@ -2305,14 +2287,14 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 227)
+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', 231)
-  def _reduce_39(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.create do |constraint_ref|
       constraint_ref.reference = val[0]
@@ -2323,5 +2305,13 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 237)
+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]
@@ -2331,5 +2321,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 241)
+module_eval(<<'.,.,', 'parser.y', 251)
   def _reduce_41(val, _values, result)
         result = val[0]
@@ -2339,5 +2329,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 245)
+module_eval(<<'.,.,', 'parser.y', 255)
   def _reduce_42(val, _values, result)
         result = val[0]
@@ -2351,5 +2341,5 @@
 # reduce 44 omitted
 
-module_eval(<<'.,.,', 'parser.y', 260)
+module_eval(<<'.,.,', 'parser.y', 271)
   def _reduce_45(val, _values, result)
         result = val[1]
@@ -2359,5 +2349,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 266)
+module_eval(<<'.,.,', 'parser.y', 277)
   def _reduce_46(val, _values, result)
         result = {:type_identifier => val[1], :c_occurrences => val[2], :absolute_path => val[3] }
@@ -2369,5 +2359,5 @@
 # reduce 47 omitted
 
-module_eval(<<'.,.,', 'parser.y', 273)
+module_eval(<<'.,.,', 'parser.y', 284)
   def _reduce_48(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.create do |archetype_slot|
@@ -2382,5 +2372,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 282)
+module_eval(<<'.,.,', 'parser.y', 293)
   def _reduce_49(val, _values, result)
         result = {:c_archetype_slot_id => val[0],:c_occurrences => val[1]}
@@ -2390,5 +2380,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 287)
+module_eval(<<'.,.,', 'parser.y', 298)
   def _reduce_50(val, _values, result)
         result = val[1]
@@ -2402,5 +2392,5 @@
 # reduce 52 omitted
 
-module_eval(<<'.,.,', 'parser.y', 295)
+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)}
@@ -2413,7 +2403,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 303)
+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
@@ -2426,7 +2416,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 312)
+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
   
@@ -2435,7 +2425,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 317)
+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
   
@@ -2444,7 +2434,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 322)
+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
   
@@ -2453,7 +2443,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 327)
+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
   
@@ -2462,7 +2452,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 332)
+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
   
@@ -2471,7 +2461,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 337)
+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
   
@@ -2480,8 +2470,8 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 342)
+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]
   
@@ -2492,5 +2482,5 @@
 # reduce 62 omitted
 
-module_eval(<<'.,.,', 'parser.y', 354)
+module_eval(<<'.,.,', 'parser.y', 365)
   def _reduce_63(val, _values, result)
         result = [val[0]]
@@ -2500,5 +2490,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 358)
+module_eval(<<'.,.,', 'parser.y', 369)
   def _reduce_64(val, _values, result)
         result = (val[0] << val[1])
@@ -2508,5 +2498,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 364)
+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)}
@@ -2519,5 +2509,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 371)
+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)}
@@ -2528,5 +2518,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 376)
+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)}
@@ -2537,7 +2527,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 383)
+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],
@@ -2550,8 +2540,8 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 392)
+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],
@@ -2564,5 +2554,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 403)
+module_eval(<<'.,.,', 'parser.y', 414)
   def _reduce_70(val, _values, result)
         result = Array[val[0]]
@@ -2572,5 +2562,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 407)
+module_eval(<<'.,.,', 'parser.y', 418)
   def _reduce_71(val, _values, result)
         result = (val[0] << val[1])
@@ -2580,5 +2570,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 411)
+module_eval(<<'.,.,', 'parser.y', 422)
   def _reduce_72(val, _values, result)
         result = Array[val[0]]
@@ -2590,5 +2580,5 @@
 # reduce 73 omitted
 
-module_eval(<<'.,.,', 'parser.y', 419)
+module_eval(<<'.,.,', 'parser.y', 430)
   def _reduce_74(val, _values, result)
         result = val[1]
@@ -2600,5 +2590,5 @@
 # reduce 75 omitted
 
-module_eval(<<'.,.,', 'parser.y', 427)
+module_eval(<<'.,.,', 'parser.y', 438)
   def _reduce_76(val, _values, result)
         result = val[1]
@@ -2624,5 +2614,5 @@
 # reduce 84 omitted
 
-module_eval(<<'.,.,', 'parser.y', 447)
+module_eval(<<'.,.,', 'parser.y', 458)
   def _reduce_85(val, _values, result)
         dadl_section = val[1]
@@ -2641,5 +2631,5 @@
 # reduce 89 omitted
 
-module_eval(<<'.,.,', 'parser.y', 462)
+module_eval(<<'.,.,', 'parser.y', 473)
   def _reduce_90(val, _values, result)
         result = Array[val[0]]
@@ -2649,5 +2639,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 466)
+module_eval(<<'.,.,', 'parser.y', 477)
   def _reduce_91(val, _values, result)
         result = (val[0] << val[1])
@@ -2657,5 +2647,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 470)
+module_eval(<<'.,.,', 'parser.y', 481)
   def _reduce_92(val, _values, result)
         result = (val[0] << val[2])
@@ -2665,7 +2655,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 475)
+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]}
   
@@ -2674,7 +2664,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 481)
+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]
   
@@ -2685,5 +2675,5 @@
 # reduce 95 omitted
 
-module_eval(<<'.,.,', 'parser.y', 488)
+module_eval(<<'.,.,', 'parser.y', 499)
   def _reduce_96(val, _values, result)
         result = val[0]
@@ -2693,5 +2683,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 492)
+module_eval(<<'.,.,', 'parser.y', 503)
   def _reduce_97(val, _values, result)
         result = val[0]
@@ -2701,5 +2691,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 497)
+module_eval(<<'.,.,', 'parser.y', 508)
   def _reduce_98(val, _values, result)
         result = val[0]
@@ -2709,5 +2699,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 501)
+module_eval(<<'.,.,', 'parser.y', 512)
   def _reduce_99(val, _values, result)
         result = val[0]
@@ -2717,5 +2707,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 506)
+module_eval(<<'.,.,', 'parser.y', 517)
   def _reduce_100(val, _values, result)
         result = {:untyped_multiple_attr_object_block => val[0]}
@@ -2725,5 +2715,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 510)
+module_eval(<<'.,.,', 'parser.y', 521)
   def _reduce_101(val, _values, result)
         result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]}
@@ -2733,5 +2723,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 515)
+module_eval(<<'.,.,', 'parser.y', 526)
   def _reduce_102(val, _values, result)
         result = {:multiple_attr_object_block_head => val[0], :keyed_objects => val[1]}
@@ -2741,7 +2731,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 520)
+module_eval(<<'.,.,', 'parser.y', 531)
   def _reduce_103(val, _values, result)
-        @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
+        @@logger.debug("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   
@@ -2750,5 +2740,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 526)
+module_eval(<<'.,.,', 'parser.y', 537)
   def _reduce_104(val, _values, result)
         result = Array[val[0]]
@@ -2758,5 +2748,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 530)
+module_eval(<<'.,.,', 'parser.y', 541)
   def _reduce_105(val, _values, result)
         result = (val[0] << val[1])
@@ -2766,7 +2756,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 535)
+module_eval(<<'.,.,', 'parser.y', 546)
   def _reduce_106(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:object_key => val[0], :object_block => val[1]}
   
@@ -2775,7 +2765,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 541)
+module_eval(<<'.,.,', 'parser.y', 552)
   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]
   
@@ -2784,5 +2774,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 547)
+module_eval(<<'.,.,', 'parser.y', 558)
   def _reduce_108(val, _values, result)
         result = {:untyped_single_attr_object_block => val[0]}
@@ -2792,5 +2782,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 551)
+module_eval(<<'.,.,', 'parser.y', 562)
   def _reduce_109(val, _values, result)
         result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]}
@@ -2800,7 +2790,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 556)
+module_eval(<<'.,.,', 'parser.y', 567)
   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]}
   
@@ -2809,7 +2799,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 561)
+module_eval(<<'.,.,', 'parser.y', 572)
   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]}
   
@@ -2820,7 +2810,7 @@
 # reduce 112 omitted
 
-module_eval(<<'.,.,', 'parser.y', 567)
+module_eval(<<'.,.,', 'parser.y', 578)
   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]}
   
@@ -2829,7 +2819,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 572)
+module_eval(<<'.,.,', 'parser.y', 583)
   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]}
   
@@ -2838,7 +2828,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 577)
+module_eval(<<'.,.,', 'parser.y', 588)
   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]
   
@@ -2847,5 +2837,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 582)
+module_eval(<<'.,.,', 'parser.y', 593)
   def _reduce_116(val, _values, result)
         result = val[0]
@@ -2855,5 +2845,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 586)
+module_eval(<<'.,.,', 'parser.y', 597)
   def _reduce_117(val, _values, result)
         result = val[0]
@@ -2863,5 +2853,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 590)
+module_eval(<<'.,.,', 'parser.y', 601)
   def _reduce_118(val, _values, result)
         result = val[0]
@@ -2871,5 +2861,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 594)
+module_eval(<<'.,.,', 'parser.y', 605)
   def _reduce_119(val, _values, result)
         result = val[0]
@@ -2879,5 +2869,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 598)
+module_eval(<<'.,.,', 'parser.y', 609)
   def _reduce_120(val, _values, result)
         result = val[0]
@@ -2887,7 +2877,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 602)
+module_eval(<<'.,.,', 'parser.y', 613)
   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]
   
@@ -2896,7 +2886,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 607)
+module_eval(<<'.,.,', 'parser.y', 618)
   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]
   
@@ -2905,7 +2895,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 612)
+module_eval(<<'.,.,', 'parser.y', 623)
   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]
   
@@ -2914,7 +2904,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 617)
+module_eval(<<'.,.,', 'parser.y', 628)
   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]
   
@@ -2923,7 +2913,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 622)
+module_eval(<<'.,.,', 'parser.y', 633)
   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]
   
@@ -2932,7 +2922,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 627)
+module_eval(<<'.,.,', 'parser.y', 638)
   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]
   
@@ -2941,7 +2931,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 632)
+module_eval(<<'.,.,', 'parser.y', 643)
   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]
   
@@ -2950,7 +2940,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 637)
+module_eval(<<'.,.,', 'parser.y', 648)
   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]
   
@@ -2959,7 +2949,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 642)
+module_eval(<<'.,.,', 'parser.y', 653)
   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]
   
@@ -2968,7 +2958,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 647)
+module_eval(<<'.,.,', 'parser.y', 658)
   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]
   
@@ -3007,7 +2997,7 @@
 # reduce 145 omitted
 
-module_eval(<<'.,.,', 'parser.y', 670)
+module_eval(<<'.,.,', 'parser.y', 681)
   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]
   
@@ -3016,7 +3006,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 675)
+module_eval(<<'.,.,', 'parser.y', 686)
   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]
   
@@ -3025,7 +3015,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 681)
+module_eval(<<'.,.,', 'parser.y', 692)
   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]
   
@@ -3040,5 +3030,5 @@
 # reduce 151 omitted
 
-module_eval(<<'.,.,', 'parser.y', 691)
+module_eval(<<'.,.,', 'parser.y', 702)
   def _reduce_152(val, _values, result)
         begin
@@ -3053,5 +3043,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 700)
+module_eval(<<'.,.,', 'parser.y', 711)
   def _reduce_153(val, _values, result)
         begin
@@ -3066,5 +3056,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 709)
+module_eval(<<'.,.,', 'parser.y', 720)
   def _reduce_154(val, _values, result)
         begin
@@ -3103,5 +3093,5 @@
 # reduce 166 omitted
 
-module_eval(<<'.,.,', 'parser.y', 735)
+module_eval(<<'.,.,', 'parser.y', 746)
   def _reduce_167(val, _values, result)
         begin
@@ -3116,5 +3106,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 744)
+module_eval(<<'.,.,', 'parser.y', 755)
   def _reduce_168(val, _values, result)
         begin
@@ -3129,5 +3119,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 753)
+module_eval(<<'.,.,', 'parser.y', 764)
   def _reduce_169(val, _values, result)
         begin
@@ -3166,5 +3156,5 @@
 # reduce 181 omitted
 
-module_eval(<<'.,.,', 'parser.y', 778)
+module_eval(<<'.,.,', 'parser.y', 789)
   def _reduce_182(val, _values, result)
         result = true
@@ -3174,5 +3164,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 782)
+module_eval(<<'.,.,', 'parser.y', 793)
   def _reduce_183(val, _values, result)
         result = false
@@ -3274,7 +3264,7 @@
 # reduce 229 omitted
 
-module_eval(<<'.,.,', 'parser.y', 845)
+module_eval(<<'.,.,', 'parser.y', 856)
   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]
   
@@ -3307,7 +3297,7 @@
 # reduce 242 omitted
 
-module_eval(<<'.,.,', 'parser.y', 865)
+module_eval(<<'.,.,', 'parser.y', 876)
   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]
   
@@ -3322,7 +3312,7 @@
 # reduce 246 omitted
 
-module_eval(<<'.,.,', 'parser.y', 875)
+module_eval(<<'.,.,', 'parser.y', 886)
   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]
   
@@ -3411,21 +3401,21 @@
 # reduce 287 omitted
 
-module_eval(<<'.,.,', 'parser.y', 945)
+module_eval(<<'.,.,', 'parser.y', 956)
   def _reduce_288(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 949)
+        @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 960)
   def _reduce_289(val, _values, result)
-        @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
-  
-    result
-  end
-.,.,
-
-module_eval(<<'.,.,', 'parser.y', 960)
+        @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 971)
   def _reduce_290(val, _values, result)
         result = Range.new(1,1)
@@ -3435,5 +3425,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 964)
+module_eval(<<'.,.,', 'parser.y', 975)
   def _reduce_291(val, _values, result)
         result = val[3]
@@ -3443,5 +3433,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 969)
+module_eval(<<'.,.,', 'parser.y', 980)
   def _reduce_292(val, _values, result)
         begin
@@ -3456,5 +3446,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 978)
+module_eval(<<'.,.,', 'parser.y', 989)
   def _reduce_293(val, _values, result)
         begin
@@ -3470,5 +3460,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 989)
+module_eval(<<'.,.,', 'parser.y', 1000)
   def _reduce_294(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new
@@ -3494,5 +3484,5 @@
 # reduce 302 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1003)
+module_eval(<<'.,.,', 'parser.y', 1014)
   def _reduce_303(val, _values, result)
         result = val[0]
@@ -3502,5 +3492,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1007)
+module_eval(<<'.,.,', 'parser.y', 1018)
   def _reduce_304(val, _values, result)
         result = val[0]
@@ -3512,5 +3502,5 @@
 # reduce 305 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1014)
+module_eval(<<'.,.,', 'parser.y', 1025)
   def _reduce_306(val, _values, result)
         result = val[3]
@@ -3612,5 +3602,5 @@
 # reduce 352 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1084)
+module_eval(<<'.,.,', 'parser.y', 1095)
   def _reduce_353(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true)
@@ -3620,5 +3610,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1088)
+module_eval(<<'.,.,', 'parser.y', 1099)
   def _reduce_354(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false)
@@ -3628,5 +3618,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1092)
+module_eval(<<'.,.,', 'parser.y', 1103)
   def _reduce_355(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,:false_valid => false)
@@ -3636,5 +3626,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1096)
+module_eval(<<'.,.,', 'parser.y', 1107)
   def _reduce_356(val, _values, result)
         result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false,:false_valid => true)
@@ -3644,5 +3634,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1101)
+module_eval(<<'.,.,', 'parser.y', 1112)
   def _reduce_357(val, _values, result)
         result = val[0]
@@ -3652,5 +3642,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1105)
+module_eval(<<'.,.,', 'parser.y', 1116)
   def _reduce_358(val, _values, result)
         raise 'Not implemented yet'
@@ -3660,5 +3650,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1109)
+module_eval(<<'.,.,', 'parser.y', 1120)
   def _reduce_359(val, _values, result)
         raise 'Not implemented yet'
@@ -3678,14 +3668,14 @@
 # reduce 364 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1121)
+module_eval(<<'.,.,', 'parser.y', 1132)
   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', 1128)
+    @@logger.debug("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
+  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'parser.y', 1139)
   def _reduce_366(val, _values, result)
           result = val[0]
@@ -3695,5 +3685,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1132)
+module_eval(<<'.,.,', 'parser.y', 1143)
   def _reduce_367(val, _values, result)
           result = val[0]
@@ -3703,5 +3693,14 @@
 .,.,
 
-# reduce 368 omitted
+module_eval(<<'.,.,', 'parser.y', 1149)
+  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
@@ -3711,5 +3710,5 @@
 # reduce 371 omitted
 
-module_eval(<<'.,.,', 'parser.y', 1147)
+module_eval(<<'.,.,', 'parser.y', 1165)
   def _reduce_372(val, _values, result)
           result = val[0]
@@ -3719,5 +3718,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1152)
+module_eval(<<'.,.,', 'parser.y', 1170)
   def _reduce_373(val, _values, result)
           result = val[0]
@@ -3727,7 +3726,7 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1156)
+module_eval(<<'.,.,', 'parser.y', 1174)
   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]
   
@@ -3736,5 +3735,5 @@
 .,.,
 
-module_eval(<<'.,.,', 'parser.y', 1167)
+module_eval(<<'.,.,', 'parser.y', 1185)
   def _reduce_375(val, _values, result)
         result = val[0]
Index: ruby/trunk/lib/adl_parser/lib/parser.y
===================================================================
--- ruby/trunk/lib/adl_parser/lib/parser.y	(revision 258)
+++ ruby/trunk/lib/adl_parser/lib/parser.y	(revision 261)
@@ -55,5 +55,5 @@
       archetype.original_language = language
     end
-    @@log.info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
     result = archetype
   }
@@ -155,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]
   }
@@ -206,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]
   }
@@ -246,4 +252,9 @@
     result = val[0]
   }
+  | v_c_domain_type
+  {
+    result = val[0]
+  }
+
 #  | v_c_domain_type
 #  | V_C_DOMAIN_TYPE
@@ -302,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
@@ -311,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
   }
@@ -342,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]
   }
@@ -382,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],
@@ -392,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],
@@ -474,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]}
   }
@@ -480,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]
   }
@@ -519,5 +530,5 @@
 multiple_attr_object_block_head: SYM_START_DBLOCK
   { 
-    @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -534,5 +545,5 @@
 keyed_object: object_key SYM_EQ object_block
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:object_key => val[0], :object_block => val[1]}
   }
@@ -540,5 +551,5 @@
 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]
   }
@@ -555,10 +566,10 @@
 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}")
+    @@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]}
   }
@@ -566,15 +577,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]
   }
@@ -601,50 +612,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]
   }
@@ -669,10 +680,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]
   }
@@ -680,5 +691,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]
   }
@@ -844,5 +855,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]
   }
@@ -864,5 +875,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]
   }
@@ -874,5 +885,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]
   }
@@ -944,9 +955,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}") 
   }
 
@@ -1121,5 +1132,5 @@
   {
     @in_interval = false
-    @@log.info("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
   }
 
@@ -1134,10 +1145,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
@@ -1155,5 +1173,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]
   }
@@ -1194,9 +1212,9 @@
 
 if $DEBUG
-  @@log = Logger.new('log/parser.log','daily')
-  @@log.level = Logger::INFO
+  @@logger = Logger.new('log/parser.log','daily')
+  @@logger.level = Logger::INFO
 else
-  @@log = Logger.new(STDOUT)
-  @@log.level = Logger::WARN
+  @@logger = Logger.new(STDOUT)
+  @@logger.level = Logger::WARN
 end
 
@@ -1263,4 +1281,5 @@
 
 def scan
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan at #{@filename}:#{@lineno}:")
   until @data.nil?  do
     case @adl_type.last
@@ -1279,4 +1298,9 @@
     when :regexp
       @data = scan_regexp(@data) do |sym, val|
+        yield sym, val
+      end
+    when :term_constraint
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+      @data = scan_term_constraint(@data) do |sym, val|
         yield sym, val
       end
@@ -1291,8 +1315,8 @@
 
 def scan_adl(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_adl at #{@filename}:#{@lineno}: data = #{data.inspect}")
   until data.nil?  do
     case @adl_type.last
     when :adl
-#      puts "Entering scan_adl"
       case data
       when /\A\n/ # carriage return
@@ -1303,5 +1327,5 @@
       when /\A--.*\n/ # single line comment
         @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
         ;
       when /\Adescription/   # description
@@ -1309,10 +1333,9 @@
       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
-      when /\A(\w+)-(\w+)-(\w+)\.(\w+)(-\w+)?\.(v[0-9]+)/   #V_ARCHETYPE_ID
+      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)
@@ -1323,8 +1346,8 @@
         word = $&
         if @@adl_reserved[word]
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: @@adl_reserved = #{@@adl_reserved[word]} at #{@filename}:#{@lineno}")
+          @@logger.debug("#{__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}")
+          @@logger.debug("#{__FILE__}:#{__LINE__}: scan_adl: V_ATTRIBUTE_IDENTIFIER = #{$&} at #{@filename}:#{@lineno}")
           yield :V_ATTRIBUTE_IDENTIFIER, $&
         end
@@ -1349,5 +1372,4 @@
         else
           adl_type = @adl_type.pop
-#          puts "Escaping #{adl_type}"
           assert_at(__FILE__,__LINE__){adl_type == :dadl}
           yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
@@ -1355,5 +1377,5 @@
       when /\A\{/   # {
         @adl_type.push(:cadl)
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
         yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
       when /\A\}/   # }
@@ -1361,5 +1383,5 @@
 #        puts "Escaping #{adl_type}"
         assert_at(__FILE__,__LINE__){adl_type == :cadl}
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
         yield :SYM_END_CBLOCK, $&
       when /\A\-/   # -
@@ -1446,20 +1468,18 @@
       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"
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan_adl: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+
       data = scan_term_constraint(data) do |sym, val|
         yield sym, val
@@ -1473,8 +1493,8 @@
 
 def scan_cadl(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_cadl at #{@filename}:#{@lineno}: data = #{data.inspect}")
   until data.nil?  do
     case @adl_type.last
     when :cadl
-#      puts "Entering scan_cadl"
       case scanned = @@cadl_scanner.parse(data)
       when Yaparc::Result::OK
@@ -1497,5 +1517,5 @@
       when /\A--.*\n/ # single line comment
         @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
         ;
         ###----------/* symbols */ ------------------------------------------------- 
@@ -1565,5 +1585,5 @@
       when /\A\{/   # {
         @adl_type.push(:cadl)
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
         yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
       when /\A\}/   # }
@@ -1571,5 +1591,5 @@
 #        puts "Escaping #{adl_type}"
         assert_at(__FILE__,__LINE__){adl_type == :cadl}
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
         yield :SYM_END_CBLOCK, :SYM_END_CBLOCK
       when /\A\$/   # $
@@ -1580,5 +1600,5 @@
         yield :Question_mark_code, :Question_mark_code
       when /\A\|/   # |
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
         if @in_interval
           @in_interval = false
@@ -1587,16 +1607,15 @@
           @in_interval = true
         end
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__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]
+      when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/  #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
+#      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]*/
+      when /\A\[([a-zA-Z0-9\(\)\._\-]+)::[ \t\n]*/
         @adl_type.push(:term_constraint)
-        yield :START_TERM_CODE_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, $&
@@ -1618,5 +1637,5 @@
           yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]
         else
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}:#{@lineno}")
+          @@logger.debug("#{__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
@@ -1654,20 +1673,18 @@
       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"
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan_cadl: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+      
       data = scan_term_constraint(data) do |sym, val|
         yield sym, val
@@ -1680,8 +1697,8 @@
 
 def scan_dadl(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_dadl at #{@filename}:#{@lineno}: data = #{data.inspect}")
   until data.nil?  do
     case @adl_type.last
     when :dadl
-#      puts "Entering scan_dadl"
       case scanned = @@dadl_scanner.parse(data)
       when Yaparc::Result::OK
@@ -1699,5 +1716,5 @@
       when /\A--.*\n/ # single line comment
         @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
         ;
         ###----------/* symbols */ ------------------------------------------------- 
@@ -1730,5 +1747,4 @@
         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, $&
@@ -1771,5 +1787,5 @@
         yield :Question_mark_code, :Question_mark_code
       when /\A\|/   # |
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
         if @in_interval
           @in_interval = false
@@ -1778,5 +1794,5 @@
           @in_interval = true
         end
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
+        @@logger.debug("#{__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]
@@ -1827,10 +1843,8 @@
       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
@@ -1842,5 +1856,6 @@
       end
     when :term_constraint
-#      puts "Entering scan_term_constraint"
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan_dadl: Entering scan_term_constraint at #{@filename}:#{@lineno}: data = #{data.inspect}")
+
       data = scan_term_constraint(data) do |sym, val|
         yield sym, val
@@ -1853,8 +1868,8 @@
 
 def scan_regexp(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_regexp at #{@filename}:#{@lineno}: data = #{data.inspect}")
   until data.nil?  do
     case @adl_type.last
     when :regexp
-#      puts "Entering scan_regexp"
       case data
       when /\A\/\}/ #V_REGEXP
@@ -1880,20 +1895,17 @@
       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"
+      @@logger.debug("#{__FILE__}:#{__LINE__}: scan_regexp: Entering scan_term_constraint at #{@filename}:#{@lineno}")
       data = scan_term_constraint(data) do |sym, val|
         yield sym, val
@@ -1906,8 +1918,8 @@
 
 def scan_term_constraint(data)
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan_term_constraint")
   until data.nil?  do
     case @adl_type.last
     when :term_constraint
-#      puts "Entering scan_term_constraint"
       case data
       when /\A\n/ # carriage return
@@ -1918,15 +1930,14 @@
       when /\A--.*$/ # single line comment
         @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_term_constraint: COMMENT = #{$&} at #{@filename}:#{@lineno}")
+        #@@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, $&
-      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 ']'
+      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, $&
+        yield :END_TERM_CODE_CONSTRAINT, $1
       else
         raise "data = #{data}"
@@ -1934,15 +1945,12 @@
       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
Index: ruby/trunk/lib/adl_parser/lib/scanner.rb
===================================================================
--- ruby/trunk/lib/adl_parser/lib/scanner.rb	(revision 258)
+++ 	(revision )
@@ -1,326 +1,0 @@
-require 'rubygems'
-gem 'yaparc'
-require 'yaparc'
-
-
-module OpenEHR
-  module ADL
-    module Scanner
-      module Common
-        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.debug("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.debug("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.debug("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.debug("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.debug("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.debug("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.debug("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.debug("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.debug("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 
-        }
-
-        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
-                              )
-            end
-          end
-        end
-=begin <DADL::Reserved class>
-=end
-        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.debug("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.debug("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.debug("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.debug("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.debug("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.debug("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.debug("V_C_DOMAIN_TYPE: #{match}")
-                [:START_V_C_DOMAIN_TYPE_BLOCK, match]
-              end
-            end
-          end
-        end
-
-        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
-                              )
-            end
-          end
-        end
-
-=begin <CADL::Reserved class>
-=end
-        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.debug("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.debug("V_ATTRIBUTE_IDENTIFIER: #{match}")
-                                [:V_ATTRIBUTE_IDENTIFIER, match]
-                              end)
-            end
-          end
-        end
-
-      end
-    end
-  end
-end
Index: ruby/trunk/lib/adl_parser/test/parser_test.rb
===================================================================
--- ruby/trunk/lib/adl_parser/test/parser_test.rb	(revision 258)
+++ ruby/trunk/lib/adl_parser/test/parser_test.rb	(revision 261)
@@ -1,3 +1,2 @@
-#require 'lib/adl_parser.rb'
 require File.dirname(__FILE__) + '/test_helper.rb'
 
@@ -7,16 +6,17 @@
   end
 
-  def test_init
+  must "assert parser instance" do
     assert_instance_of ::OpenEHR::ADL::Parser,@parser
   end
 
-  def test_parse
+  must "openEHR-EHR-OBSERVATION.body_mass_index.v1.adl be properly parsed" do
     body_mass_index =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl")
-#    body_mass_index = File.read('test/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl')
     assert_nothing_raised do
       ast = @parser.parse(body_mass_index, 'openEHR-EHR-OBSERVATION.body_mass_index.v1.adl')
       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
     laboratory_request = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl")
     assert_nothing_raised do
@@ -26,5 +26,7 @@
       assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, result.definition
     end
-
+  end
+
+  must "openEHR-EHR-OBSERVATION.apgar.v1.adl be properly parsed" do
     apgar = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl")
     assert_nothing_raised do
@@ -34,135 +36,186 @@
       assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, result.definition
     end
-
+  end
+
+  must "openEHR-EHR-EVALUATION.adverse.v1.adl be properly parsed" do
     evaluation = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-EVALUATION.adverse.v1.adl")
     assert_nothing_raised do
       @parser.parse(evaluation, 'openEHR-EHR-EVALUATION.adverse.v1')
     end
-
+  end
+
+  must "openEHR-EHR-ITEM_TREE.referral.v1.adl be properly parsed" do
     referral = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ITEM_TREE.referral.v1.adl")
     assert_nothing_raised do
       @parser.parse(referral, 'openEHR-EHR-ITEM_TREE.referral.v1')
     end
-
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-fetus.v1.adl be properly parsed" do
     exam_fetus = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-fetus.v1.adl")
     assert_nothing_raised do
       @parser.parse(exam_fetus, 'openEHR-EHR-CLUSTER.exam-fetus.v1')
     end
-
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl be properly parsed" do
     exam_uterine_cervix = File.read("#{TEST_ROOT_DIR}/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')
     end
-
+  end
+
+  must "openEHR-EHR-ACTION.imaging.v1.adl be properly parsed" do
     imaging = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ACTION.imaging.v1.adl")
     assert_nothing_raised do
       @parser.parse(imaging, 'openEHR-EHR-ACTION.imaging.v1')
     end
-
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl be properly parsed" do
     exam_nervous_system = File.read("#{TEST_ROOT_DIR}/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')
     end
-
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-generic.v1.adl be properly parsed" do
     exam_generic = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic.v1.adl")
     assert_nothing_raised do
       @parser.parse(exam_generic, 'openEHR-EHR-CLUSTER.exam-generic.v1')
     end
-
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl be properly parsed" do
     exam_generic_mass = File.read("#{TEST_ROOT_DIR}/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')
     end
-
-#     exam_generic_lymphnode = File.read("#{TEST_ROOT_DIR}/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')
-#     end
-
-#     exam_generic_joint = File.read("#{TEST_ROOT_DIR}/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')
-#     end
-
-#     exam_chest = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-chest.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(exam_chest, 'openEHR-EHR-CLUSTER.exam-chest.v1')
-#     end
-
-#     exam_abdomen = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-abdomen.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(exam_abdomen, 'openEHR-EHR-CLUSTER.exam-abdomen.v1')
-#     end
-
-#     cluster_auscultation = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.auscultation.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(cluster_auscultation, 'openEHR-EHR-CLUSTER.auscultation.v1')
-#     end
-
-#     cluster_auscultation_chest = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.auscultation-chest.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(cluster_auscultation_chest, 'openEHR-EHR-CLUSTER.auscultation-chest.v1')
-#     end
-
-#     vital_signs = File.read("#{TEST_ROOT_DIR}/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_ROOT_DIR}/adl/openEHR-EHR-SECTION.summary.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(summary, 'openEHR-EHR-SECTION.summary.v1')
-#     end
-
-#     findings = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.findings.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(findings, 'openEHR-EHR-SECTION.findings.v1')
-#     end
-
-#     reason_for_encounter = File.read("#{TEST_ROOT_DIR}/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')
-#     end
-
-#     imaging = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ITEM_TREE.imaging.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(imaging, 'openEHR-EHR-ITEM_TREE.imaging.v1')
-#     end
-
-#     instruction_referral = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-INSTRUCTION.referral.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(instruction_referral, 'openEHR-EHR-INSTRUCTION.referral.v1')
-#     end
-
-#     instruction_medication = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-INSTRUCTION.medication.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(instruction_medication, 'openEHR-EHR-INSTRUCTION.medication.v1')
-#     end
-
-#     action_referral = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ACTION.referral.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(action_referral, 'openEHR-EHR-ACTION.referral.v1')
-#     end
-
-#     dimensions_circumference = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.dimensions.v1.adl")
-#     assert_nothing_raised do
-#       @parser.parse(dimensions_circumference, 'openEHR-EHR-CLUSTER.dimensions.v1')
-#     end
-
-#     discharge = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-COMPOSITION.discharge.v1draft.adl")
-#     assert_nothing_raised do
-#       @parser.parse(discharge, 'openEHR-EHR-COMPOSITION.discharge.v1draft')
-#     end
-
-#     encounter = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl")
-#     assert_nothing_raised do
-#       @parser.parse(encounter, 'openEHR-EHR-COMPOSITION.encounter.v1draft')
-#     end
-
-
-#     medication = File.read("#{TEST_ROOT_DIR}/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 "openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl be properly parsed" do
+    exam_generic_lymphnode = File.read("#{TEST_ROOT_DIR}/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')
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl be properly parsed" do
+    exam_generic_joint = File.read("#{TEST_ROOT_DIR}/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')
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-chest.v1.adl be properly parsed" do
+    exam_chest = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-chest.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(exam_chest, 'openEHR-EHR-CLUSTER.exam-chest.v1')
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.exam-abdomen.v1.adl be properly parsed" do
+    exam_abdomen = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-abdomen.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(exam_abdomen, 'openEHR-EHR-CLUSTER.exam-abdomen.v1')
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.auscultation.v1.adl be properly parsed" do
+    cluster_auscultation = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.auscultation.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(cluster_auscultation, 'openEHR-EHR-CLUSTER.auscultation.v1')
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.auscultation-chest.v1.adl be properly parsed" do
+    cluster_auscultation_chest = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.auscultation-chest.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(cluster_auscultation_chest, 'openEHR-EHR-CLUSTER.auscultation-chest.v1')
+    end
+  end
+
+  must "openEHR-EHR-SECTION.vital_signs.v1.adl be properly parsed" do
+    vital_signs = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.vital_signs.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(vital_signs, 'openEHR-EHR-SECTION.vital_signs.v1')
+    end
+  end
+
+  must "openEHR-EHR-SECTION.summary.v1.adl be properly parsed" do
+    summary = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.summary.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(summary, 'openEHR-EHR-SECTION.summary.v1')
+    end
+  end
+
+  must "openEHR-EHR-SECTION.findings.v1.adl be properly parsed" do
+    findings = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.findings.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(findings, 'openEHR-EHR-SECTION.findings.v1')
+    end
+  end
+
+  must "openEHR-EHR-SECTION.reason_for_encounter.v1.adl be properly parsed" do
+    reason_for_encounter = File.read("#{TEST_ROOT_DIR}/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')
+    end
+  end
+
+  must "openEHR-EHR-ITEM_TREE.imaging.v1.adl be properly parsed" do
+    imaging = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ITEM_TREE.imaging.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(imaging, 'openEHR-EHR-ITEM_TREE.imaging.v1')
+    end
+  end
+
+  must "openEHR-EHR-INSTRUCTION.referral.v1.adl be properly parsed" do
+    instruction_referral = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-INSTRUCTION.referral.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(instruction_referral, 'openEHR-EHR-INSTRUCTION.referral.v1')
+    end
+  end
+
+  must "openEHR-EHR-INSTRUCTION.medication.v1.adl be properly parsed" do
+    instruction_medication = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-INSTRUCTION.medication.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(instruction_medication, 'openEHR-EHR-INSTRUCTION.medication.v1')
+    end
+  end
+
+  must "openEHR-EHR-ACTION.referral.v1.adl be properly parsed" do
+    action_referral = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ACTION.referral.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(action_referral, 'openEHR-EHR-ACTION.referral.v1')
+    end
+  end
+
+  must "openEHR-EHR-CLUSTER.dimensions.v1.adl be properly parsed" do
+    dimensions_circumference = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.dimensions.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(dimensions_circumference, 'openEHR-EHR-CLUSTER.dimensions.v1')
+    end
+  end
+
+  must "openEHR-EHR-COMPOSITION.discharge.v1draft.adl be properly parsed" do
+    discharge = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-COMPOSITION.discharge.v1draft.adl")
+    assert_nothing_raised do
+      @parser.parse(discharge, 'openEHR-EHR-COMPOSITION.discharge.v1draft')
+    end
+  end
+
+  must "openEHR-EHR-COMPOSITION.encounter.v1draft.adl be properly parsed" do
+    encounter = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl")
+    assert_nothing_raised do
+      @parser.parse(encounter, 'openEHR-EHR-COMPOSITION.encounter.v1draft')
+    end
+  end
+
+  must "openEHR-EHR-ITEM_TREE.medication.v1.adl be properly parsed" do
+    medication = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ITEM_TREE.medication.v1.adl")
+    assert_nothing_raised do
+      @parser.parse(medication, 'openEHR-EHR-ITEM_TREE.medication.v1.adl')
+    end
   end
 end
Index: ruby/trunk/lib/adl_parser/test/scanner_test.rb
===================================================================
--- ruby/trunk/lib/adl_parser/test/scanner_test.rb	(revision 258)
+++ ruby/trunk/lib/adl_parser/test/scanner_test.rb	(revision 261)
@@ -1,8 +1,6 @@
-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
+  must "assert root scanner instance" do
     parser = OpenEHR::ADL::Scanner::DADL::RootScanner.new
     assert_instance_of OpenEHR::ADL::Scanner::DADL::RootScanner,parser
@@ -10,5 +8,6 @@
   end
 
-  def test_V_LOCAL_TERM_CODE_REF
+  # \[{ALPHANUM}{NAMECHAR}*\]
+  must "assert V_LOCAL_TERM_CODE_REF scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::Common::V_LOCAL_TERM_CODE_REF.new
     assert_instance_of OpenEHR::ADL::Scanner::Common::V_LOCAL_TERM_CODE_REF,parser
@@ -17,5 +16,5 @@
   end
 
-  def test_V_QUALIFIED_TERM_CODE_REF
+  must "assert V_QUALIFIED_TERM_CODE_REF scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF.new
     assert_instance_of OpenEHR::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF,parser
@@ -26,5 +25,5 @@
   end
 
-  def test_V_STRING
+  must "assert V_STRING scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::Common::V_STRING.new
     assert_instance_of OpenEHR::ADL::Scanner::Common::V_STRING,parser
@@ -35,5 +34,5 @@
   end
 
-  def test_V_REAL
+  must "assert V_REAL scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::Common::V_REAL.new
     assert_instance_of OpenEHR::ADL::Scanner::Common::V_REAL,parser
@@ -46,5 +45,5 @@
   end
 
-  def test_V_ISO8601_DURATION
+  must "assert V_ISO8601_DURATION scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::Common::V_ISO8601_DURATION.new
     assert_instance_of OpenEHR::ADL::Scanner::Common::V_ISO8601_DURATION,parser
@@ -56,5 +55,5 @@
   end
 
-  def test_V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN
+  must "assert V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN scanner is properly working" do
     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
@@ -63,5 +62,5 @@
   end
 
-  def test_V_ISO8601_DATE_CONSTRAINT_PATTERN
+  must "assert V_ISO8601_DATE_CONSTRAINT_PATTERN scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::CADL::V_ISO8601_DATE_CONSTRAINT_PATTERN.new
     assert_instance_of OpenEHR::ADL::Scanner::CADL::V_ISO8601_DATE_CONSTRAINT_PATTERN,parser
@@ -70,5 +69,5 @@
   end
 
-  def test_V_ISO8601_TIME_CONSTRAINT_PATTERN
+  must "assert V_ISO8601_TIME_CONSTRAINT_PATTERN scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::CADL::V_ISO8601_TIME_CONSTRAINT_PATTERN.new
     assert_instance_of OpenEHR::ADL::Scanner::CADL::V_ISO8601_TIME_CONSTRAINT_PATTERN,parser
@@ -77,5 +76,5 @@
   end
 
-  def test_dadl_reserved
+  must "assert reserved words in dADL scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::DADL::RootScanner.new
     result = parser.parse('then')
@@ -86,5 +85,5 @@
   end
 
-  def test_cadl
+  must "assert reserved words in cADL scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::CADL::RootScanner.new
     assert_instance_of OpenEHR::ADL::Scanner::CADL::RootScanner,parser
@@ -97,5 +96,5 @@
   end
 
-  def test_cadl_reserved
+  must "assert other reserved words in cADL scanner is properly working" do
     parser = OpenEHR::ADL::Scanner::CADL::RootScanner.new
     result = parser.parse('then')
@@ -109,5 +108,3 @@
     assert_equal [:SYM_ORDERED, :SYM_ORDERED], result.value
   end
-
-  
 end
Index: ruby/trunk/lib/adl_parser/test/semantic_test.rb
===================================================================
--- ruby/trunk/lib/adl_parser/test/semantic_test.rb	(revision 258)
+++ ruby/trunk/lib/adl_parser/test/semantic_test.rb	(revision 261)
@@ -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/trunk/lib/adl_parser/test/shell_test.rb
===================================================================
--- ruby/trunk/lib/adl_parser/test/shell_test.rb	(revision 258)
+++ ruby/trunk/lib/adl_parser/test/shell_test.rb	(revision 261)
@@ -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/trunk/lib/adl_parser/test/test_helper.rb
===================================================================
--- ruby/trunk/lib/adl_parser/test/test_helper.rb	(revision 258)
+++ ruby/trunk/lib/adl_parser/test/test_helper.rb	(revision 261)
@@ -5,6 +5,24 @@
 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/trunk/lib/adl_parser/test/validator_test.rb
===================================================================
--- ruby/trunk/lib/adl_parser/test/validator_test.rb	(revision 258)
+++ ruby/trunk/lib/adl_parser/test/validator_test.rb	(revision 261)
@@ -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
