Index: ruby/trunk/adl_parser/lib/parser.y
===================================================================
--- ruby/trunk/adl_parser/lib/parser.y	(revision 26)
+++ ruby/trunk/adl_parser/lib/parser.y	(revision 32)
@@ -160,5 +160,5 @@
 
 #c_complex_object: c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body SYM_END_CBLOCK
-c_complex_object: c_complex_object_head SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi
+c_complex_object: c_complx_object_head SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi
   { 
     result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
@@ -203,33 +203,40 @@
 
 c_object: v_c_domain_type
-  { 
+  {
     result = val[0]
   }
   | c_complex_object
-  { 
-    result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new
+  {
+    @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")
+    result = val[0]
   }
   | archetype_internal_ref
-  { 
-    result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new
+  {
+    result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.create do |archetype_internal_ref|
+      archetype_internal_ref.target_path = val[0][:absolute_path]
+      archetype_internal_ref.rm_type_name = val[0][:type_identifier]
+      archetype_internal_ref.occurrences = val[0][:c_occurrences]
+    end
   }
   | archetype_slot
-  { 
-    result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new
+  {
+    result = val[0]
   }
   | constraint_ref
-  { 
-    result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new
+  {
+    result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.create do |constraint_ref|
+      constraint_ref.reference = val[0]
+    end
   }
   | c_code_phrase
-  { 
+  {
     result = val[0]
   }
   | c_ordinal
-  { 
+  {
     result = val[0]
   }
   | c_primitive_object
-  { 
+  {
     result = val[0]
   }
@@ -252,12 +259,28 @@
 # 'archetype_internal_ref' is a node that refers to a previously defined object node in the same archetype.
 archetype_internal_ref: SYM_USE_NODE type_identifier c_occurrences absolute_path
+  {
+    result = {:type_identifier => val[1], :c_occurrences => val[2], :absolute_path => val[3] }
+  }
   | SYM_USE_NODE type_identifier error
 
 # 'archetype_slot' is a node whose statements define a constraint that determines which other archetypes may appear at that point in the current archetype.
 archetype_slot: c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK c_includes c_excludes SYM_END_CBLOCK
-
+  {
+    result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.create do |archetype_slot|
+      archetype_slot.includes = val[3]
+      archetype_slot.excludes = val[4]
+      archetype_slot.rm_type_name = val[0][:c_archetype_slot_id]
+      archetype_slot.occurrences = val[0][:c_occurrences]
+    end
+  }
 c_archetype_slot_head: c_archetype_slot_id c_occurrences
+  {
+    result = {:c_archetype_slot_id => val[0],:c_occurrences => val[1]}
+  }
 
 c_archetype_slot_id: SYM_ALLOW_ARCHETYPE type_identifier
+  {
+    result = val[1]
+  }
   | SYM_ALLOW_ARCHETYPE type_identifier V_LOCAL_TERM_CODE_REF
   | SYM_ALLOW_ARCHETYPE error
@@ -267,5 +290,7 @@
   {
     assert_at(__FILE__,__LINE__){val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE)}
-    result = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.new(:item => val[0])
+    result = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.create do |c_primitive_object|
+      c_primitive_object.item = val[0]
+    end
   }
 
@@ -273,5 +298,9 @@
   {
     @@log.info("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")
-    result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.new
+    result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.create do |c_integer|
+      c_integer.list
+      c_integer.range
+      c_integer.assumed_value
+    end
   }
   | c_real
@@ -383,4 +412,7 @@
 c_includes: #-- Empty
     | SYM_INCLUDE invariants
+{
+    result = val[1]
+}
 
 ### c_excludes: #-- Empty
@@ -388,4 +420,7 @@
 c_excludes: #-- Empty
     | SYM_EXCLUDE invariants
+{
+    result = val[1]
+}
 
 invariants: invariant
@@ -1080,5 +1115,11 @@
 #c_code_phrase: V_TERM_CODE_CONSTRAINT #-- e.g. "[local::at0040, at0041; at0040]"
 c_code_phrase: term_code_constraint_section #-- e.g. "[local::at0040, at0041; at0040]"
+  {
+      result = val[0]
+  }
   | V_QUALIFIED_TERM_CODE_REF
+  {
+      result = val[0]
+  }
 
 #term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body Right_bracket_code
@@ -1093,9 +1134,16 @@
 # A Constraint_Ref is a proxy for a set of constraints on an object.
 constraint_ref: V_LOCAL_TERM_CODE_REF #-- e.g. "ac0003"
+  {
+      result = val[0]
+  }
 
 any_identifier: type_identifier
+  {
+      result = val[0]
+  }
   | V_ATTRIBUTE_IDENTIFIER
   {
     @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
+      result = val[0]
   }
 
