Changeset 23 for ruby/trunk/adl_parser/lib/parser.y
- Timestamp:
- May 1, 2008, 8:21:09 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/adl_parser/lib/parser.y
r22 r23 106 106 { 107 107 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}") 109 109 result = val[0] 110 110 } 111 111 | assertions 112 { 113 result = val[0] 114 } 112 115 # | error 113 116 … … 115 118 c_complex_object: c_complex_object_head SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi 116 119 { 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 118 125 } 119 126 | c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body SYM_END_CBLOCK 120 127 { 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 125 133 } 126 134 # | c_complex_object_head error SYM_END_CBLOCK … … 128 136 129 137 c_complex_object_head: c_complex_object_id c_occurrences 138 { 139 result = {:c_complex_object_id => val[0], :c_occurrences => val[1]} 140 } 130 141 131 142 c_complex_object_id: type_identifier 132 143 { 133 result = val[0]144 result = {:type_identifier => val[0]} 134 145 } 135 146 | type_identifier V_LOCAL_TERM_CODE_REF 136 147 { 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]} 138 149 } 139 150 … … 191 202 192 203 v_c_domain_type: START_V_C_DOMAIN_TYPE_BLOCK dadl_section END_V_C_DOMAIN_TYPE_BLOCK 204 { 205 result = val[1] 206 } 193 207 194 208 # 'archetype_internal_ref' is a node that refers to a previously defined object node in the same archetype. … … 348 362 arch_ontology: SYM_ONTOLOGY dadl_section 349 363 { 364 dadl_sections = val[1] 350 365 result = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new 351 366 } … … 361 376 362 377 attr_vals: attr_val 378 { 379 result = Array[val[0]] 380 } 363 381 | attr_vals attr_val 382 { 383 result = (val[0] << val[1]) 384 } 364 385 | attr_vals Semicolon_code attr_val 365 # | attr_vals ';' attr_val 386 { 387 result = (val[0] << val[2]) 388 } 366 389 367 390 attr_val: attr_id SYM_EQ object_block 368 391 { 369 392 @@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]} 370 394 } 371 395 … … 397 421 multiple_attr_object_block: untyped_multiple_attr_object_block 398 422 { 399 result = val[0]423 result = {:untyped_multiple_attr_object_block => val[0]} 400 424 } 401 425 | type_identifier untyped_multiple_attr_object_block 402 426 { 403 result = val[0]427 result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]} 404 428 } 405 429 406 430 untyped_multiple_attr_object_block: multiple_attr_object_block_head keyed_objects SYM_END_DBLOCK 407 431 { 408 result = val[0]432 result = {:multiple_attr_object_block_head => val[0], :keyed_objects => val[1]} 409 433 } 410 434 … … 416 440 417 441 keyed_objects: keyed_object 442 { 443 result = Array[val[0]] 444 } 418 445 | keyed_objects keyed_object 446 { 447 result = (val[0] << val[1]) 448 } 419 449 420 450 keyed_object: object_key SYM_EQ object_block 421 451 { 422 452 @@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]} 423 454 } 424 455 … … 430 461 431 462 single_attr_object_block: untyped_single_attr_object_block 463 { 464 result = {:untyped_single_attr_object_block => val[0]} 465 } 432 466 | type_identifier untyped_single_attr_object_block 467 { 468 result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]} 469 } 470 433 471 untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # <> 434 472 { 435 473 @@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]} 437 475 } 438 476 | single_attr_object_complex_head attr_vals SYM_END_DBLOCK 439 477 { 440 478 @@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]} 442 480 } 443 481 single_attr_object_complex_head: SYM_START_DBLOCK … … 445 483 { 446 484 @@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]} 448 486 } 449 487 | type_identifier untyped_primitive_object_block 450 488 { 451 489 @@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]} 453 491 } 454 492 untyped_primitive_object_block: SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK … … 611 649 612 650 real_value: V_REAL 651 { 652 begin 653 real = Float(val[0]) 654 rescue 655 raise 656 end 657 result = real 658 } 613 659 | Plus_code V_REAL 660 { 661 begin 662 real = Float(val[0]) 663 rescue 664 raise 665 end 666 result = real 667 } 614 668 | 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 } 617 677 618 678 real_list_value: real_value Comma_code real_value … … 632 692 633 693 boolean_value: SYM_TRUE 694 { 695 result = true 696 } 634 697 | SYM_FALSE 698 { 699 result = false 700 } 635 701 636 702 boolean_list_value: boolean_value Comma_code boolean_value … … 854 920 c_occurrences: #-- default to 1..1 855 921 | SYM_OCCURRENCES SYM_MATCHES SYM_START_CBLOCK occurrence_spec SYM_END_CBLOCK 922 { 923 result = val[3] 924 } 856 925 | SYM_OCCURRENCES error 857 926
Note:
See TracChangeset
for help on using the changeset viewer.