Index: ruby/branches/0.5/lib/adl_parser/lib/parser.y
===================================================================
--- ruby/branches/0.5/lib/adl_parser/lib/parser.y	(revision 169)
+++ ruby/branches/0.5/lib/adl_parser/lib/parser.y	(revision 290)
@@ -40,4 +40,5 @@
     
     archetype_id = val[0][:archetype_id]
+    parent_archtype_id = val[1][:parent_archtype_id] if val[1]
     adl_version = val[0][:arch_head][:arch_meta_data][:adl_version]
     concept = val[2]
@@ -45,4 +46,5 @@
     archetype = OpenEHR::AM::Archetype::ARCHETYPE.create(
                                                          :archetype_id => archetype_id,
+                                                         :parent_archtype_id => parent_archtype_id,
                                                          :adl_version => adl_version,
                                                          :concept => concept,
@@ -53,5 +55,5 @@
       archetype.original_language = language
     end
-    @@log.info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: archetype = #{archetype.to_yaml} at #{@filename}:#{@lineno}")
     result = archetype
   }
@@ -104,4 +106,7 @@
 arch_specialisation: #-- empty is ok
   | SYM_SPECIALIZE V_ARCHETYPE_ID
+  {
+    result = {:parent_archtype_id => val[1]}
+  }
   | SYM_SPECIALIZE error
 
@@ -150,5 +155,5 @@
   {
     assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT)}
-    @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -201,12 +206,18 @@
 
 #------------------------- node types -----------------------
-
-c_object: v_c_domain_type
-  {
-    result = val[0]
-  }
-  | c_complex_object
-  {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")
+### http://www.openehr.org/svn/ref_impl_eiffel/TRUNK/components/adl_parser/src/syntax/cadl/parser/cadl_validator.html
+### c_object:  c_complex_object
+### | archetype_internal_ref
+### | archetype_slot
+### | constraint_ref
+### | c_code_phrase
+### | c_ordinal
+### | c_primitive_object
+### | V_C_DOMAIN_TYPE
+### | ERR_C_DOMAIN_TYPE
+### | error
+c_object: c_complex_object
+  {
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -241,4 +252,9 @@
     result = val[0]
   }
+  | v_c_domain_type
+  {
+    result = val[0]
+  }
+
 #  | v_c_domain_type
 #  | V_C_DOMAIN_TYPE
@@ -297,5 +313,5 @@
 c_primitive: c_integer
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.create do |c_integer|
       c_integer.list
@@ -306,30 +322,30 @@
   | c_real
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new
   }
   | c_date
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new
   }
   | c_time
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new
   }
   | c_date_time
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new
   }
   | c_duration
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new
   }
   | c_string
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}")
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new
   }
@@ -337,5 +353,5 @@
   {
     assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN)}
-    @@log.info("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -377,5 +393,5 @@
 c_attr_head: V_ATTRIBUTE_IDENTIFIER c_existence
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}")
     result = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new(
                                                                               :rm_attribute_name => val[0],
@@ -387,5 +403,5 @@
   {
     assert_at(__FILE__,__LINE__){ val[2].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY) }
-    @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}") 
     result = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new(
                                                                                 :rm_attribute_name => val[0],
@@ -469,5 +485,5 @@
 attr_val: attr_id SYM_EQ object_block
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:attr_id => val[0], :object_block => val[2]}
   }
@@ -475,5 +491,5 @@
 attr_id: V_ATTRIBUTE_IDENTIFIER
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -514,5 +530,4 @@
 multiple_attr_object_block_head: SYM_START_DBLOCK
   { 
-    @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -529,11 +544,11 @@
 keyed_object: object_key SYM_EQ object_block
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
-    result = {:object_key => val[0], :object_block => val[1]}
+    @@logger.debug("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]} at #{@filename}:#{@lineno}")
+    result = {:object_key => val[0], :object_block => val[2]}
   }
 
 object_key: Left_bracket_code simple_value Right_bracket_code
   {
-    @@log.info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
+    @@logger.debug("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
     result = val[1]
   }
@@ -548,12 +563,12 @@
   }
 
-untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # <>
-  {
-    @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
+untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # >
+  {
+    @@logger.debug("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:single_attr_object_complex_head => val[0]}
   }
   | single_attr_object_complex_head attr_vals SYM_END_DBLOCK
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]}, attr_vals = #{val[1]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: attr_vals = #{val[1]} at #{@filename}:#{@lineno}")
     result = {:single_attr_object_complex_head => val[0], :attr_vals => val[1]}
   }
@@ -561,15 +576,15 @@
 primitive_object_block: untyped_primitive_object_block
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")
     result = {:untyped_primitive_object_block => val[0]}
   }
   | type_identifier untyped_primitive_object_block
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")
     result = {:type_identifier => val[0], :untyped_primitive_object_block => val[1]}
   }
 untyped_primitive_object_block: SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}")
     result = val[1]
   }
@@ -596,50 +611,50 @@
 simple_value: string_value
   {
-    @@log.info("string_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("string_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | integer_value
   {
-    @@log.info("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | real_value
   {
-    @@log.info("real_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("real_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | boolean_value
   {
-    @@log.info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | character_value
   {
-    @@log.info("character_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("character_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | date_value
   {
-    @@log.info("date_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("date_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | time_value
   {
-    @@log.info("time_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("time_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | date_time_value
   {
-    @@log.info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | duration_value
   {
-    @@log.info("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | uri_value
   {
-    @@log.info("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -664,10 +679,10 @@
 type_identifier: V_TYPE_IDENTIFIER
   {
-    @@log.info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
   | V_GENERIC_TYPE_IDENTIFIER
   {
-    @@log.info("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -675,5 +690,5 @@
 string_value: V_STRING
   {
-    @@log.info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -790,4 +805,7 @@
 
 date_value: V_ISO8601_EXTENDED_DATE
+  { 
+    result = val[0]
+  }
 
 date_list_value: date_value Comma_code date_value
@@ -839,5 +857,5 @@
 duration_value: V_ISO8601_DURATION
   {
-    @@log.info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -859,5 +877,5 @@
 term_code: V_QUALIFIED_TERM_CODE_REF
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -869,5 +887,5 @@
 uri_value: V_URI
   {
-    @@log.info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
     result = val[0]
   }
@@ -939,9 +957,9 @@
 path_segment: V_ATTRIBUTE_IDENTIFIER V_LOCAL_TERM_CODE_REF
   {
-    @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
   }
   | V_ATTRIBUTE_IDENTIFIER
   {
-    @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 
   }
 
@@ -1116,5 +1134,5 @@
   {
     @in_interval = false
-    @@log.info("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
+    @@logger.debug("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 
   }
 
@@ -1129,10 +1147,17 @@
   }
 
-#term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body Right_bracket_code
+#                             [[a-zA-Z0-9\(\)\._\-]+::[ \t\n]*          [[a-zA-Z0-9\._\-]*[ \t]*]
 term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT
+  {
+    @@logger.debug("#{__FILE__}:#{__LINE__}, START_TERM_CODE_CONSTRAINT = #{val[0]} at #{@filename}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}, term_code_body = #{val[1]}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}, END_TERM_CODE_CONSTRAINT = #{val[2]}")
+    result = val[1]
+  }
+
+
 term_code_body: # empty
   | TERM_CODE
   | term_code_body TERM_CODE
-### term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT
 ### term_code_body: TERM_CODE
 ###   | term_code_body TERM_CODE
@@ -1150,5 +1175,5 @@
   | V_ATTRIBUTE_IDENTIFIER
   {
-    @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
+    @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
       result = val[0]
   }
@@ -1171,9 +1196,9 @@
 $:.unshift File.join(File.dirname(__FILE__))
 require 'logger'
-#require 'lib/util.rb'
-#require 'lib/scanner.rb'
-require 'lib/adl_parser.rb'
+require 'yaml'
 require 'rubygems'
+require 'adl_parser.rb'
 require 'am.rb'
+require 'rm.rb'
 $DEBUG = false
 
@@ -1189,13 +1214,11 @@
 
 if $DEBUG
-  @@log = Logger.new('log/parser.log','daily')
-  @@log.level = Logger::INFO
+  @@logger = Logger.new('log/parser.log','daily')
+  @@logger.level = Logger::DEBUG
 else
-  @@log = Logger.new(STDOUT)
-  @@log.level = Logger::WARN
+  @@logger = Logger.new(STDOUT)
+  @@logger.level = Logger::WARN
 end
 
-@@dadl_scanner = OpenEHR::ADL::Scanner::DADL::RootScanner.new
-@@cadl_scanner = OpenEHR::ADL::Scanner::CADL::RootScanner.new
 
 ###----------/* keywords */ --------------------------------------------- 
@@ -1257,25 +1280,12 @@
 ###----------/* Scanner */ ----------------------------------------------- 
 
+
 def scan
+  @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan at #{@filename}:#{@lineno}:")
+  scanner = OpenEHR::ADL::Scanner::ADLScanner.new(@adl_type, @filename)
+
   until @data.nil?  do
-    case @adl_type.last
-    when :adl
-      @data = scan_adl(@data) do |sym, val|
+    @data = scanner.scan(@data) do |sym, val|
         yield sym, val
-      end
-    when :dadl
-      @data = scan_dadl(@data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-      @data = scan_cadl(@data) do |sym, val|
-        yield sym, val
-      end
-    when :regexp
-      @data = scan_regexp(@data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
     end
     @data = $' # variable $' receives the string after the match
@@ -1284,664 +1294,4 @@
   yield false, '$'
 end # of scan
-
-def scan_adl(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :adl
-#      puts "Entering scan_adl"
-      case data
-      when /\A\n/ # carriage return
-        @lineno += 1
-        ;
-      when /\A[ \t\r\f]+/ #just drop it
-        ;
-      when /\A--.*\n/ # single line comment
-        @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
-        ;
-      when /\Adescription/   # description
-        yield :SYM_DESCRIPTION, :SYM_DESCRIPTION
-      when /\Adefinition/   # definition
-        yield :SYM_DEFINITION, :SYM_DEFINITION
-#        @adl_type.push(:cadl)
-        ###----------/* symbols */ ------------------------------------------------- 
-      when /\A[A-Z][a-zA-Z0-9_]*/
-        yield :V_TYPE_IDENTIFIER, $&
-      when /\A[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z0-9]+/   #V_ARCHETYPE_ID
-        yield :V_ARCHETYPE_ID, $&
-      when /\A[a-z][a-zA-Z0-9_]*/
-#        word = $&.downcase
-        word = $&
-        if @@adl_reserved[word]
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: @@adl_reserved = #{@@adl_reserved[word]} at #{@filename}:#{@lineno}")
-          yield @@adl_reserved[word], @@adl_reserved[word]
-        elsif #/\A[A-Z][a-zA-Z0-9_]*/
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: V_ATTRIBUTE_IDENTIFIER = #{$&} at #{@filename}:#{@lineno}")
-          yield :V_ATTRIBUTE_IDENTIFIER, $&
-        end
-      when /\A\=/   # =
-        yield :SYM_EQ, :SYM_EQ
-      when /\A\>=/   # >=
-        yield :SYM_GE, :SYM_GE
-      when /\A\<=/   # <=
-        yield :SYM_LE, :SYM_LE
-      when /\A\</   # <
-        if @in_interval
-#          @start_block_received = false
-          yield :SYM_LT, :SYM_LT
-        else
-#          @start_block_received = true
-          @adl_type.push(:dadl)
-          yield :SYM_START_DBLOCK,  $&
-        end
-      when /\A\>/   # >
-        if @in_interval
-          yield :SYM_GT, :SYM_GT
-        else
-          adl_type = @adl_type.pop
-#          puts "Escaping #{adl_type}"
-          assert_at(__FILE__,__LINE__){adl_type == :dadl}
-          yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
-        end
-      when /\A\{/   # {
-        @adl_type.push(:cadl)
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
-        yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
-      when /\A\}/   # }
-        adl_type = @adl_type.pop
-#        puts "Escaping #{adl_type}"
-        assert_at(__FILE__,__LINE__){adl_type == :cadl}
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
-        yield :SYM_END_CBLOCK, $&
-      when /\A\-/   # -
-        yield :Minus_code, :Minus_code
-      when /\A\+/   # +
-        yield :Plus_code, :Plus_code
-      when /\A\*/   # *
-        yield :Star_code, :Star_code
-      when /\A\//   # /
-        yield :Slash_code, :Slash_code
-      when /\A\^/   # ^
-        yield :Caret_code, :Caret_code
-      when /\A\=/   # =
-        yield :Equal_code, :Equal_code
-      when /\A\.\.\./   # ...
-        yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
-      when /\A\.\./   # ..
-        yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
-      when /\A\./   # .
-        yield :Dot_code, :Dot_code
-      when /\A\;/   # ;
-        yield :Semicolon_code, :Semicolon_code
-      when /\A\,/   # ,
-        yield :Comma_code, :Comma_code
-      when /\A\:/   # :
-        yield :Colon_code, :Colon_code
-      when /\A\!/   # !
-        yield :Exclamation_code, :Exclamation_code
-      when /\A\(/   # (
-        yield :Left_parenthesis_code, :Left_parenthesis_code
-      when /\A\)/   # )
-        yield :Right_parenthesis_code, :Right_parenthesis_code
-      when /\A\$/   # $
-        yield :Dollar_code, :Dollar_code
-      when /\A\?\?/   # ??
-        yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
-      when /\A\?/   # ?
-        yield :Question_mark_code, :Question_mark_code
-      when /\A[0-9]+\.[0-9]+(\.[0-9]+)*/   # ?
-        yield :V_VERSION_STRING, :V_VERSION_STRING
-      when /\A\|/   # |
-        if @in_interval
-          @in_interval = false
-        else
-          @in_interval = true
-        end
-        yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
-      when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/
-#      when /\A\[[a-zA-Z0-9()\._-]+\:\:[a-zA-Z0-9\._-]+\]/   #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
-        yield :V_QUALIFIED_TERM_CODE_REF, $&
-      when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/   #V_LOCAL_TERM_CODE_REF
-        yield :V_LOCAL_TERM_CODE_REF, $&
-      when /\A\[/   # [
-        yield :Left_bracket_code, :Left_bracket_code
-      when /\A\]/   # ]
-        yield :Right_bracket_code, :Right_bracket_code
-
-      when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/   #ERR_V_QUALIFIED_TERM_CODE_REF
-        yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
-      when /\Aa[ct][0-9.]+/   #V_LOCAL_CODE
-        yield :V_LOCAL_CODE, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/   #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
-        yield :V_ISO8601_EXTENDED_DATE_TIME, $&
-      when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? /   #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
-        yield :V_ISO8601_EXTENDED_TIME, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/   #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
-        yield :V_ISO8601_EXTENDED_DATE, $&
-      when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/   #V_GENERIC_TYPE_IDENTIFIER
-        yield :V_GENERIC_TYPE_IDENTIFIER, $&
-      when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/   #V_INTEGER
-        yield :V_INTEGER, $&
-      when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ /   #V_REAL
-        yield :V_REAL, $&
-        #    when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
-      when /\A"([^"]*)"/m #V_STRING
-        yield :V_STRING, $1
-      when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
-        yield :V_URI, $&
-      when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/   #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
-        yield :V_ISO8601_DURATION, $&
-      when /\A\S/ #UTF8CHAR
-        yield :UTF8CHAR, $&
-      end
-      data = $' # variable $' receives the string after the match
-    when :dadl
-#      puts "Entering scan_dadl"
-      data = scan_dadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-#      puts "Entering scan_cadl"
-      data = scan_cadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :regexp
-#      puts "Entering scan_regexp"
-      data = scan_regexp(data) do |sym, val|
-        yield sym, val
-      end
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      data = scan_term_constraint(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end
-end # scan_adl
-
-
-def scan_cadl(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :cadl
-#      puts "Entering scan_cadl"
-      case scanned = @@cadl_scanner.parse(data)
-      when Yaparc::Result::OK
-        if scanned.value[0] == :START_V_C_DOMAIN_TYPE_BLOCK
-          @in_c_domain_type = true
-          @adl_type.push(:dadl)
-          yield scanned.value
-        else
-          yield scanned.value
-        end
-        data = scanned.input
-      end
-
-      case data
-      when /\A\n/ # carriage return
-        @lineno += 1
-        ;
-      when /\A[ \t\r\f]+/ #just drop it
-        ;
-      when /\A--.*\n/ # single line comment
-        @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
-        ;
-        ###----------/* symbols */ ------------------------------------------------- 
-      when /\A\=/   # =
-        yield :SYM_EQ, :SYM_EQ
-      when /\A\>=/   # >=
-        yield :SYM_GE, :SYM_GE
-      when /\A\<=/   # <=
-        yield :SYM_LE, :SYM_LE
-###       when /\A[A-Z][a-zA-Z0-9_]*[ \n]*\</   # V_C_DOMAIN_TYPE
-###         @in_c_domain_type = true
-###         @adl_type.push(:dadl)
-###         yield :START_V_C_DOMAIN_TYPE_BLOCK, $&
-      when /\A\</   # <
-        if @in_interval
-          yield :SYM_LT, :SYM_LT
-        else
-          @adl_type.push(:dadl)
-          yield :SYM_START_DBLOCK,  $&
-        end
-      when /\A\>/   # >
-        if @in_interval
-          yield :SYM_GT, :SYM_GT
-        else
-          adl_type = @adl_type.pop
-#          puts "Escaping #{adl_type}"
-          assert_at(__FILE__,__LINE__){adl_type == :dadl}
-          yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
-        end
-      when /\A\-/   # -
-        yield :Minus_code, :Minus_code
-      when /\A\+/   # +
-        yield :Plus_code, :Plus_code
-      when /\A\*/   # *
-        yield :Star_code, :Star_code
-      when /\A\//   # /
-        yield :Slash_code, :Slash_code
-      when /\A\^/   # ^
-        yield :Caret_code, :Caret_code
-      when /\A\.\.\./   # ...
-        yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
-      when /\A\.\./   # ..
-        yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
-      when /\A\./   # .
-        yield :Dot_code, :Dot_code
-      when /\A\;/   # ;
-        yield :Semicolon_code, :Semicolon_code
-      when /\A\,/   # ,
-        yield :Comma_code, :Comma_code
-      when /\A\:/   # :
-        yield :Colon_code, :Colon_code
-      when /\A\!/   # !
-        yield :Exclamation_code, :Exclamation_code
-      when /\A\(/   # (
-        yield :Left_parenthesis_code, :Left_parenthesis_code
-      when /\A\)/   # )
-        yield :Right_parenthesis_code, :Right_parenthesis_code
-      when /\A\{\// #V_REGEXP
-        if @adl_type.last != :regexp
-          @in_regexp = true
-          @adl_type.push(:regexp)
-          yield :START_REGEXP_BLOCK, :START_REGEXP_BLOCK
-        else
-          raise
-        end
-#        yield :V_REGEXP, :V_REGEXP
-      when /\A\{/   # {
-        @adl_type.push(:cadl)
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
-        yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
-      when /\A\}/   # }
-        adl_type = @adl_type.pop
-#        puts "Escaping #{adl_type}"
-        assert_at(__FILE__,__LINE__){adl_type == :cadl}
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
-        yield :SYM_END_CBLOCK, :SYM_END_CBLOCK
-      when /\A\$/   # $
-        yield :Dollar_code, :Dollar_code
-      when /\A\?\?/   # ??
-        yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
-      when /\A\?/   # ?
-        yield :Question_mark_code, :Question_mark_code
-      when /\A\|/   # |
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
-        if @in_interval
-          @in_interval = false
-        else
-#          @in_interval = false
-          @in_interval = true
-        end
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
-        yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
-
-      when /\A\[[a-zA-Z0-9._\-]+::[a-zA-Z0-9._\-]+\]/   #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
-        yield :V_QUALIFIED_TERM_CODE_REF, $&
-      when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/   #ERR_V_QUALIFIED_TERM_CODE_REF
-        yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
-      when /\A\[([a-zA-Z0-9()._\-]+::[a-zA-Z0-9._\_-]+)\]/
-        yield :V_TERM_CODE_CONSTRAINT, :V_TERM_CODE_CONSTRAINT
-      when /\A\[[a-zA-Z0-9\(\)\._\-]+::[ \t\n]*/
-        @adl_type.push(:term_constraint)
-        yield :START_TERM_CODE_CONSTRAINT, $&
-      when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/   #V_LOCAL_TERM_CODE_REF
-        yield :V_LOCAL_TERM_CODE_REF, $&
-      when /\A\[/   # [
-        yield :Left_bracket_code, :Left_bracket_code
-      when /\A\]/   # ]
-        yield :Right_bracket_code, :Right_bracket_code
-      when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/   #V_GENERIC_TYPE_IDENTIFIER
-        yield :V_GENERIC_TYPE_IDENTIFIER, $&
-      when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X][T\t][hH?X][hH?X]:[mM?X][mM?X]:[sS?X][sS?X]/
-        yield :V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN, $&
-      when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X]/
-        yield :V_ISO8601_DATE_CONSTRAINT_PATTERN, $&
-      when /\A[hH][hH]:[mM?X][mM?X]:[sS?X][sS?X]/
-        yield :V_ISO8601_TIME_CONSTRAINT_PATTERN, $&
-      when /\A[a-z][a-zA-Z0-9_]*/
-        word = $&.dup
-        if @@cadl_reserved[word.downcase]
-          yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]
-        else
-          @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}:#{@lineno}")
-          yield :V_ATTRIBUTE_IDENTIFIER, word #V_ATTRIBUTE_IDENTIFIER /\A[a-z][a-zA-Z0-9_]*/
-        end
-      when /\A[A-Z][a-zA-Z0-9_]*/
-        word = $&.dup
-        if @@cadl_reserved[word.downcase]
-          yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]
-        else
-          yield :V_TYPE_IDENTIFIER, $&
-        end
-      when /\Aa[ct][0-9.]+/   #V_LOCAL_CODE
-        yield :V_LOCAL_CODE, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/   #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
-        yield :V_ISO8601_EXTENDED_DATE_TIME, $&
-      when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? /   #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
-        yield :V_ISO8601_EXTENDED_TIME, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/   #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
-        yield :V_ISO8601_EXTENDED_DATE, $&
-      when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/   #V_INTEGER
-        yield :V_INTEGER, $&
-      when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ /   #V_REAL
-        yield :V_REAL, $&
-           when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
-      when /\A"([^"]*)"/m #V_STRING
-        yield :V_STRING, $1
-      when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
-        yield :V_URI, $&
-###       when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/   #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
-###         yield :V_ISO8601_DURATION, $&
-      when /\A\S/ #UTF8CHAR
-        yield :UTF8CHAR, $&
-      else
-        raise
-      end
-      data = $' # variable $' receives the string after the match
-    when :adl
-#      puts "Entering scan_adl"
-      data = scan_adl(data) do |sym, val|
-        yield sym, val
-      end
-    when :dadl
-#      puts "Entering scan_dadl"
-      data = scan_dadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :regexp
-#      puts "Entering scan_regexp"
-      data = scan_regexp(data) do |sym, val|
-        yield sym, val
-      end
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      data = scan_term_constraint(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end # of until
-end # of scan_cadl
-
-def scan_dadl(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :dadl
-#      puts "Entering scan_dadl"
-      case scanned = @@dadl_scanner.parse(data)
-      when Yaparc::Result::OK
-        yield scanned.value
-        data = scanned.input
-      else
-      end
-
-      case data
-      when /\A\n/ # carriage return
-        @lineno += 1
-        ;
-      when /\A[ \t\r\f]+/ #just drop it
-        ;
-      when /\A--.*\n/ # single line comment
-        @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
-        ;
-        ###----------/* symbols */ ------------------------------------------------- 
-      when /\A\=/   # =
-        yield :SYM_EQ, :SYM_EQ
-      when /\A\>\=/   # >=
-        yield :SYM_GE, :SYM_GE
-      when /\A\<\=/   # <=
-        yield :SYM_LE, :SYM_LE
-      when /\A\</   # <
-        if @in_interval
-          yield :SYM_LT, :SYM_LT
-        else
-          @adl_type.push(:dadl)
-          yield :SYM_START_DBLOCK, :SYM_START_DBLOCK
-        end
-      when /\A\>/   # >
-        if @in_interval
-#          @in_interval = false
-          yield :SYM_GT, :SYM_GT
-        elsif @in_c_domain_type == true
-          assert_at(__FILE__,__LINE__){@adl_type.last == :dadl}
-          adl_type = @adl_type.pop
-          if @adl_type.last == :cadl
-            @in_c_domain_type = false
-            yield :END_V_C_DOMAIN_TYPE_BLOCK, $&
-          else
-            yield :SYM_END_DBLOCK, $&
-          end
-        elsif @in_c_domain_type == false
-          adl_type = @adl_type.pop
-#          puts "Escaping #{adl_type}"
-          assert_at(__FILE__,__LINE__){adl_type == :dadl}
-          yield :SYM_END_DBLOCK, $&
-        else
-          raise
-        end
-      when /\A\-/   # -
-        yield :Minus_code, :Minus_code
-      when /\A\+/   # +
-        yield :Plus_code, :Plus_code
-      when /\A\*/   # *
-        yield :Star_code, :Star_code
-      when /\A\//   # /
-        yield :Slash_code, :Slash_code
-      when /\A\^/   # ^
-        yield :Caret_code, :Caret_code
-      when /\A\.\.\./   # ...
-        yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
-      when /\A\.\./   # ..
-        yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
-      when /\A\./   # .
-        yield :Dot_code, :Dot_code
-      when /\A\;/   # ;
-        yield :Semicolon_code, :Semicolon_code
-      when /\A\,/   # ,
-        yield :Comma_code, :Comma_code
-      when /\A\:/   # :
-        yield :Colon_code, :Colon_code
-      when /\A\!/   # !
-        yield :Exclamation_code, :Exclamation_code
-      when /\A\(/   # (
-        yield :Left_parenthesis_code, :Left_parenthesis_code
-      when /\A\)/   # )
-        yield :Right_parenthesis_code, :Right_parenthesis_code
-      when /\A\$/   # $
-        yield :Dollar_code, :Dollar_code
-      when /\A\?\?/   # ??
-        yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
-      when /\A\?/   # ?
-        yield :Question_mark_code, :Question_mark_code
-      when /\A\|/   # |
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
-        if @in_interval
-          @in_interval = false
-        else
-#          @in_interval = false
-          @in_interval = true
-        end
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
-        yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
-###       when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/   #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
-###         yield :V_QUALIFIED_TERM_CODE_REF, $&
-###       when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/   #V_LOCAL_TERM_CODE_REF
-###         yield :V_LOCAL_TERM_CODE_REF, $&
-###       when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/   #ERR_V_QUALIFIED_TERM_CODE_REF
-###         yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
-      when /\A\[/   # [
-        yield :Left_bracket_code, :Left_bracket_code
-      when /\A\]/   # ]
-        yield :Right_bracket_code, :Right_bracket_code
-###       when /\A[A-Z][a-zA-Z0-9_-]*/
-###         yield :V_TYPE_IDENTIFIER, $&
-###       when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/   #V_GENERIC_TYPE_IDENTIFIER
-###         yield :V_GENERIC_TYPE_IDENTIFIER, $&
-###       when /\A[a-z][a-zA-Z0-9_]*/
-###         word = $&.downcase
-###         if @@dadl_reserved[word]
-###           yield @@dadl_reserved[word], @@dadl_reserved[word]
-###         else
-###           yield :V_ATTRIBUTE_IDENTIFIER, $&
-###         end
-###       when /\Aa[ct][0-9.]+/   #V_LOCAL_CODE
-###         yield :V_LOCAL_CODE, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/   #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
-        yield :V_ISO8601_EXTENDED_DATE_TIME, $&
-      when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? /   #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
-        yield :V_ISO8601_EXTENDED_TIME, $&
-      when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/   #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
-        yield :V_ISO8601_EXTENDED_DATE, $&
-      when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/   #V_GENERIC_TYPE_IDENTIFIER
-        yield :V_GENERIC_TYPE_IDENTIFIER, $&
-      when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/   #V_INTEGER
-        yield :V_INTEGER, $&
-###       when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ /   #V_REAL
-###         yield :V_REAL, $&
-        #    when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
-###       when /\A"([^"]*)"/m #V_STRING
-###         yield :V_STRING, $1
-      when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
-        yield :V_URI, $&
-###       when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/   #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
-###         yield :V_ISO8601_DURATION, $&
-      when /\A\S/ #UTF8CHAR
-        yield :UTF8CHAR, $&
-      end
-      data = $' # variable $' receives the string after the match
-    when :adl
-#      puts "Entering scan_adl"
-      data = scan_adl(data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-#      puts "Entering scan_cadl"
-      data = scan_cadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :regexp
-#      puts "Entering scan_regexp"
-      data = scan_regexp(data) do |sym, val|
-        yield sym, val
-      end
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      data = scan_term_constraint(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end
-end # of scan_dadl
-
-def scan_regexp(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :regexp
-#      puts "Entering scan_regexp"
-      case data
-      when /\A\/\}/ #V_REGEXP
-        if @adl_type.last == :regexp
-          @in_regexp = false
-          @adl_type.pop
-          yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK
-        else
-          raise
-        end
-      when /\A(.*)(\/\})/ #V_REGEXP
-        yield :REGEXP_BODY, $1
-        if @adl_type.last == :regexp
-          @in_regexp = false
-          @adl_type.pop
-          yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK
-        else
-          raise
-        end
-      else
-        raise data
-      end
-      data = $' # variable $' receives the string after the match
-    when :adl
-#      puts "Entering scan_adl"
-      data = scan_adl(data) do |sym, val|
-        yield sym, val
-      end
-    when :dadl
-#      puts "Entering scan_dadl"
-      data = scan_dadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-#      puts "Entering scan_cadl"
-      data = scan_cadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      data = scan_term_constraint(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end
-end # of scan_regexp
-
-def scan_term_constraint(data)
-  until data.nil?  do
-    case @adl_type.last
-    when :term_constraint
-#      puts "Entering scan_term_constraint"
-      case data
-      when /\A\n/ # carriage return
-        @lineno += 1
-        ;
-      when /\A[ \t\r\f]+/ #just drop it
-        ;
-      when /\A--.*$/ # single line comment
-        @lineno += 1
-        @@log.info("#{__FILE__}:#{__LINE__}: scan_term_constraint: COMMENT = #{$&} at #{@filename}:#{@lineno}")
-        ;
-      when /\A[a-zA-Z0-9\._\-]+[ \t]*,/ # match any line, with ',' termination
-        yield :TERM_CODE, $&
-      when /\A[a-zA-Z0-9\._\-]+[ \t]*;/ #match second last line with ';' termination (assumed value)
-        yield :TERM_CODE, $&
-#      when /\A[a-zA-Z0-9\._\-]+[ \t]*\]/ # match final line, terminating in ']'
-      when /\A[a-zA-Z0-9\._\-]*[ \t]*\]/ # match final line, terminating in ']'
-        adl_type = @adl_type.pop
-        assert_at(__FILE__,__LINE__){adl_type == :term_constraint}
-        yield :END_TERM_CODE_CONSTRAINT, $&
-      else
-        raise "data = #{data}"
-      end
-      data = $' # variable $' receives the string after the match
-    when :adl
-#      puts "Entering scan_adl"
-      data = scan_adl(data) do |sym, val|
-        yield sym, val
-      end
-    when :dadl
-#      puts "Entering scan_dadl"
-      data = scan_dadl(data) do |sym, val|
-        yield sym, val
-      end
-    when :cadl
-#      puts "Entering scan_cadl"
-      data = scan_cadl(data) do |sym, val|
-        yield sym, val
-      end
-    else
-      raise
-    end
-  end
-end # of scan_term_constraint
 
 
@@ -1964,5 +1314,5 @@
 
 
-
+__END__
 
 
