Ignore:
Timestamp:
May 1, 2008, 8:21:09 AM (16 years ago)
Author:
Tatsukawa, Akimichi
Message:

working on adl_parser semantic functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/adl_parser/lib/parser.y

    r22 r23  
    106106  {
    107107    assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT)}
    108                      
     108    @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}")
    109109    result = val[0]
    110110  }
    111111  | assertions
     112  {
     113    result = val[0]
     114  }
    112115#  | error
    113116
     
    115118c_complex_object: c_complex_object_head SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi
    116119  {
    117     result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new
     120    result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
     121      c_complex_object.node_id = val[0][:c_complex_object_id][:local_term_code_ref]
     122      c_complex_object.rm_type_name = val[0][:c_complex_object_id][:type_identifier]
     123      c_complex_object.occurrences = val[0][:c_occurrences]
     124    end
    118125  }
    119126    | c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body SYM_END_CBLOCK
    120127  {
    121     result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(
    122                                                                             :assumed_value => val[0],
    123                                                                             :attributes => val[2]
    124                                                                             )
     128    result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
     129      c_complex_object.node_id = val[0][:c_complex_object_id][:local_term_code_ref]
     130      c_complex_object.rm_type_name = val[0][:c_complex_object_id][:type_identifier]
     131      c_complex_object.occurrences = val[0][:c_occurrences]
     132    end
    125133  }
    126134#    | c_complex_object_head error SYM_END_CBLOCK
     
    128136
    129137c_complex_object_head: c_complex_object_id c_occurrences
     138  {
     139    result = {:c_complex_object_id => val[0], :c_occurrences => val[1]}
     140  }
    130141
    131142c_complex_object_id: type_identifier
    132143  {
    133     result = val[0]
     144    result = {:type_identifier => val[0]}
    134145  }
    135146  | type_identifier V_LOCAL_TERM_CODE_REF
    136147  {
    137     result = {:c_complex_object_id => {:type_identifier => val[0], :V_LOCAL_TERM_CODE_REF => val[1]}}
     148    result = {:type_identifier => val[0], :local_term_code_ref => val[1]}
    138149  }
    139150
     
    191202
    192203v_c_domain_type: START_V_C_DOMAIN_TYPE_BLOCK dadl_section END_V_C_DOMAIN_TYPE_BLOCK
     204  {
     205    result = val[1]
     206  }
    193207
    194208# 'archetype_internal_ref' is a node that refers to a previously defined object node in the same archetype.
     
    348362arch_ontology: SYM_ONTOLOGY dadl_section
    349363  {
     364    dadl_sections = val[1]
    350365    result = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new
    351366  }
     
    361376
    362377attr_vals: attr_val
     378  {
     379    result = Array[val[0]]
     380  }
    363381  | attr_vals attr_val
     382  {
     383    result = (val[0] << val[1])
     384  }
    364385  | attr_vals Semicolon_code attr_val
    365 #  | attr_vals ';' attr_val
     386  {
     387    result = (val[0] << val[2])
     388  }
    366389
    367390attr_val: attr_id SYM_EQ object_block
    368391  {
    369392    @@log.info("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
     393    result = {:attr_id => val[0], :object_block => val[2]}
    370394  }
    371395
     
    397421multiple_attr_object_block: untyped_multiple_attr_object_block
    398422  {
    399     result = val[0]
     423    result = {:untyped_multiple_attr_object_block => val[0]}
    400424  }
    401425  | type_identifier untyped_multiple_attr_object_block
    402426  {
    403     result = val[0]
     427    result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]}
    404428  }
    405429
    406430untyped_multiple_attr_object_block: multiple_attr_object_block_head keyed_objects SYM_END_DBLOCK
    407431  {
    408     result = val[0]
     432    result = {:multiple_attr_object_block_head => val[0], :keyed_objects => val[1]}
    409433  }
    410434
     
    416440
    417441keyed_objects: keyed_object
     442  {
     443    result = Array[val[0]]
     444  }
    418445  | keyed_objects keyed_object
     446  {
     447    result = (val[0] << val[1])
     448  }
    419449
    420450keyed_object: object_key SYM_EQ object_block
    421451  {
    422452    @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
     453    result = {:object_key => val[0], :object_block => val[1]}
    423454  }
    424455
     
    430461
    431462single_attr_object_block: untyped_single_attr_object_block
     463  {
     464    result = {:untyped_single_attr_object_block => val[0]}
     465  }
    432466  | type_identifier untyped_single_attr_object_block
     467  {
     468    result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]}
     469  }
     470
    433471untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # <>
    434472  {
    435473    @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
    436     result = val[0]
     474    result = {:single_attr_object_complex_head => val[0]}
    437475  }
    438476  | single_attr_object_complex_head attr_vals SYM_END_DBLOCK
    439477  {
    440478    @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]}, attr_vals = #{val[1]} at #{@filename}:#{@lineno}")
    441     result = val[0]
     479    result = {:single_attr_object_complex_head => val[0], :attr_vals => val[1]}
    442480  }
    443481single_attr_object_complex_head: SYM_START_DBLOCK
     
    445483  {
    446484    @@log.info("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")
    447     result = val[0]
     485    result = {:untyped_primitive_object_block => val[0]}
    448486  }
    449487  | type_identifier untyped_primitive_object_block
    450488  {
    451489    @@log.info("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")
    452     result = val[0]
     490    result = {:type_identifier => val[0], :untyped_primitive_object_block => val[1]}
    453491  }
    454492untyped_primitive_object_block: SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK
     
    611649
    612650real_value: V_REAL
     651  {
     652    begin
     653      real = Float(val[0])
     654    rescue
     655      raise
     656    end
     657    result = real
     658  }
    613659  | Plus_code V_REAL
     660  {
     661    begin
     662      real = Float(val[0])
     663    rescue
     664      raise
     665    end
     666    result = real
     667  }
    614668  | Minus_code V_REAL
    615 #  | '+' V_REAL
    616 #  | '-' V_REAL
     669  {
     670    begin
     671      real = Float(val[0])
     672    rescue
     673      raise
     674    end
     675    result = - real
     676  }
    617677
    618678real_list_value: real_value Comma_code real_value
     
    632692
    633693boolean_value: SYM_TRUE
     694  {
     695    result = true
     696  }
    634697  | SYM_FALSE
     698  {
     699    result = false
     700  }
    635701
    636702boolean_list_value: boolean_value Comma_code boolean_value
     
    854920c_occurrences:  #-- default to 1..1
    855921  | SYM_OCCURRENCES SYM_MATCHES SYM_START_CBLOCK occurrence_spec SYM_END_CBLOCK
     922  {
     923    result = val[3]
     924  }
    856925  | SYM_OCCURRENCES error
    857926
Note: See TracChangeset for help on using the changeset viewer.