Changes in ruby/trunk/adl_parser/lib/parser.y [20:26]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/adl_parser/lib/parser.y
r20 r26 28 28 29 29 input: archetype EOF 30 { 31 result = val[0] 32 } 30 33 | error 31 34 32 archetype: arch_identification 33 arch_specialisation 34 arch_concept 35 arch_language 36 arch_description 37 arch_definition 38 arch_invariant 39 arch_ontology 35 archetype: arch_identification arch_specialisation arch_concept arch_language arch_description arch_definition arch_invariant arch_ontology 36 { 37 assert_at(__FILE__,__LINE__) do 38 val[4].instance_of?(OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION) and val[5].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT) and val[7].instance_of?(OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY) 39 end 40 41 archetype_id = val[0][:archetype_id] 42 adl_version = val[0][:arch_head][:arch_meta_data][:adl_version] 43 concept = val[2] 44 language = val[3][:arch_language] 45 archetype = OpenEHR::AM::Archetype::ARCHETYPE.create( 46 :archetype_id => archetype_id, 47 :adl_version => adl_version, 48 :concept => concept, 49 :description => val[4], 50 :definition => val[5], 51 :ontology => val[7] 52 ) do |archetype| 53 archetype.original_language = language 54 end 55 @@log.info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}") 56 result = archetype 57 } 40 58 41 59 42 60 arch_identification: arch_head V_ARCHETYPE_ID 61 { 62 result = {:arch_head => val[0], :archetype_id => val[1] } 63 } 43 64 | SYM_ARCHETYPE error 65 { 66 raise 67 } 44 68 45 69 arch_head: SYM_ARCHETYPE 70 { 71 result = {:arch_meta_data => nil } 72 } 46 73 | SYM_ARCHETYPE arch_meta_data 74 { 75 result = val[1] 76 } 47 77 48 78 arch_meta_data: Left_parenthesis_code arch_meta_data_items Right_parenthesis_code 79 { 80 result = {:arch_meta_data => val[1] } 81 } 49 82 50 83 arch_meta_data_items: arch_meta_data_item 84 { 85 result = val[0] 86 } 51 87 | arch_meta_data_items Semicolon_code arch_meta_data_item 52 # | arch_meta_data_items ';' arch_meta_data_item 88 { 89 result = val[0].merge(val[2]) 90 } 91 53 92 54 93 arch_meta_data_item: SYM_ADL_VERSION SYM_EQ V_VERSION_STRING 94 { 95 result = {:adl_version => val[2], :is_controlled => false } 96 } 55 97 | SYM_IS_CONTROLLED 98 { 99 result = {:is_controlled => true } 100 } 56 101 57 102 # Define specialization in which its constraints are narrower than those of the parent. … … 62 107 63 108 arch_concept: SYM_CONCEPT V_LOCAL_TERM_CODE_REF 109 { 110 result = {:arch_concept => val[1] } 111 } 64 112 | SYM_CONCEPT error 65 113 … … 69 117 70 118 arch_language: #-- empty is ok for ADL 1.4 tools 119 { 120 result = {:arch_language => nil} 121 } 71 122 | SYM_LANGUAGE dadl_section 72 123 { 73 result = {: language => val[1]}124 result = {:arch_language => val[1]} 74 125 } 75 126 | SYM_LANGUAGE error … … 81 132 arch_description: #-- no meta-data ok 82 133 | SYM_DESCRIPTION dadl_section 83 | SYM_DESCRIPTION error 84 134 { 135 result = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new(:details => val[1]) 136 } 137 | SYM_DESCRIPTION error 138 85 139 #arch_definition: SYM_DEFINITION V_CADL_TEXT 86 140 # | SYM_DEFINITION error 87 141 arch_definition: SYM_DEFINITION cadl_section 142 { 143 result = val[1] 144 } 88 145 | SYM_DEFINITION error 89 146 … … 91 148 ### cADL section 92 149 cadl_section: c_complex_object 150 { 151 assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT)} 152 @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}") 153 result = val[0] 154 } 93 155 | assertions 156 { 157 result = val[0] 158 } 94 159 # | error 95 160 96 161 #c_complex_object: c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body SYM_END_CBLOCK 97 162 c_complex_object: c_complex_object_head SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi 163 { 164 result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object| 165 c_complex_object.node_id = val[0][:c_complex_object_id][:local_term_code_ref] 166 c_complex_object.rm_type_name = val[0][:c_complex_object_id][:type_identifier] 167 c_complex_object.occurrences = val[0][:c_occurrences] 168 end 169 } 98 170 | c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body SYM_END_CBLOCK 99 # | c_complex_object_head error SYM_END_CBLOCK 100 # { 101 # @adl_type.push(:cadl) 102 # yyerror 103 # } 171 { 172 result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object| 173 c_complex_object.node_id = val[0][:c_complex_object_id][:local_term_code_ref] 174 c_complex_object.rm_type_name = val[0][:c_complex_object_id][:type_identifier] 175 c_complex_object.occurrences = val[0][:c_occurrences] 176 end 177 } 178 # | c_complex_object_head error SYM_END_CBLOCK 104 179 # | c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body c_invariants SYM_END_CBLOCK 105 180 106 181 c_complex_object_head: c_complex_object_id c_occurrences 182 { 183 result = {:c_complex_object_id => val[0], :c_occurrences => val[1]} 184 } 107 185 108 186 c_complex_object_id: type_identifier 109 187 { 110 result = {: c_complex_object_id => {:type_identifier => val[0]}}188 result = {:type_identifier => val[0]} 111 189 } 112 190 | type_identifier V_LOCAL_TERM_CODE_REF 113 191 { 114 result = {: c_complex_object_id => {:type_identifier => val[0], :V_LOCAL_TERM_CODE_REF => val[1]}}192 result = {:type_identifier => val[0], :local_term_code_ref => val[1]} 115 193 } 116 194 117 195 c_complex_object_body: c_any #-- used to indicate that any value of a type is ok 118 196 | c_attributes 197 { 198 result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => val[0]) 199 } 119 200 120 201 … … 122 203 123 204 c_object: v_c_domain_type 205 { 206 result = val[0] 207 } 124 208 | c_complex_object 209 { 210 result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new 211 } 125 212 | archetype_internal_ref 213 { 214 result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new 215 } 126 216 | archetype_slot 217 { 218 result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new 219 } 127 220 | constraint_ref 221 { 222 result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new 223 } 128 224 | c_code_phrase 225 { 226 result = val[0] 227 } 129 228 | c_ordinal 229 { 230 result = val[0] 231 } 130 232 | c_primitive_object 233 { 234 result = val[0] 235 } 131 236 # | v_c_domain_type 132 237 # | V_C_DOMAIN_TYPE … … 141 246 142 247 v_c_domain_type: START_V_C_DOMAIN_TYPE_BLOCK dadl_section END_V_C_DOMAIN_TYPE_BLOCK 248 { 249 result = val[1] 250 } 143 251 144 252 # 'archetype_internal_ref' is a node that refers to a previously defined object node in the same archetype. … … 157 265 # 'c_primitive_object' is an node representing a constraint on a primitive object type. 158 266 c_primitive_object: c_primitive 267 { 268 assert_at(__FILE__,__LINE__){val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE)} 269 result = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.new(:item => val[0]) 270 } 159 271 160 272 c_primitive: c_integer 273 { 274 @@log.info("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}") 275 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.new 276 } 161 277 | c_real 278 { 279 @@log.info("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}") 280 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new 281 } 162 282 | c_date 283 { 284 @@log.info("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}") 285 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new 286 } 163 287 | c_time 288 { 289 @@log.info("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}") 290 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new 291 } 164 292 | c_date_time 293 { 294 @@log.info("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}") 295 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new 296 } 165 297 | c_duration 298 { 299 @@log.info("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}") 300 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new 301 } 166 302 | c_string 303 { 304 @@log.info("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}") 305 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new 306 } 167 307 | c_boolean 308 { 309 assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN)} 310 @@log.info("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}") 311 result = val[0] 312 } 168 313 169 314 c_any: Star_code … … 173 318 174 319 c_attributes: c_attribute 320 { 321 result = [val[0]] 322 } 175 323 | c_attributes c_attribute 324 { 325 result = (val[0] << val[1]) 326 } 176 327 177 328 # 'c_attribute' is a node representing a constraint on an attribute in an object model. 178 329 c_attribute: c_attr_head SYM_MATCHES SYM_START_CBLOCK c_attr_values SYM_END_CBLOCK 330 { 331 assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)} 332 c_attribute = val[0] 333 c_attribute.children = val[3] 334 result = c_attribute 335 } 179 336 | c_attr_head SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi 337 { 338 assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)} 339 result = val[0] 340 } 180 341 | c_attr_head SYM_MATCHES SYM_START_CBLOCK error SYM_END_CBLOCK 342 { 343 assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)} 344 result = val[0] 345 } 181 346 182 347 … … 184 349 { 185 350 @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}") 351 result = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new( 352 :rm_attribute_name => val[0], 353 :existence => val[1] 354 ) 355 186 356 } 187 357 | V_ATTRIBUTE_IDENTIFIER c_existence c_cardinality 188 358 { 359 assert_at(__FILE__,__LINE__){ val[2].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY) } 189 360 @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}") 361 result = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new( 362 :rm_attribute_name => val[0], 363 :existence => val[1], 364 :cardinality => val[2] 365 ) 190 366 } 191 367 192 368 c_attr_values: c_object 369 { 370 result = Array[val[0]] 371 } 193 372 | c_attr_values c_object 373 { 374 result = (val[0] << val[1]) 375 } 194 376 | c_any # -- to allow a property to have any value 377 { 378 result = Array[val[0]] 379 } 195 380 196 381 ### c_includes: #-- Empty … … 220 405 221 406 arch_ontology: SYM_ONTOLOGY dadl_section 407 { 408 dadl_section = val[1] 409 result = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new 410 } 222 411 | SYM_ONTOLOGY error 223 412 … … 231 420 232 421 attr_vals: attr_val 422 { 423 result = Array[val[0]] 424 } 233 425 | attr_vals attr_val 426 { 427 result = (val[0] << val[1]) 428 } 234 429 | attr_vals Semicolon_code attr_val 235 # | attr_vals ';' attr_val 430 { 431 result = (val[0] << val[2]) 432 } 236 433 237 434 attr_val: attr_id SYM_EQ object_block 238 435 { 239 436 @@log.info("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}") 437 result = {:attr_id => val[0], :object_block => val[2]} 240 438 } 241 439 … … 243 441 { 244 442 @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}") 443 result = val[0] 245 444 } 246 445 | V_ATTRIBUTE_IDENTIFIER error 247 446 248 447 object_block: complex_object_block 448 { 449 result = val[0] 450 } 249 451 | primitive_object_block 452 { 453 result = val[0] 454 } 250 455 251 456 complex_object_block: single_attr_object_block 457 { 458 result = val[0] 459 } 252 460 | multiple_attr_object_block 461 { 462 result = val[0] 463 } 253 464 254 465 multiple_attr_object_block: untyped_multiple_attr_object_block 466 { 467 result = {:untyped_multiple_attr_object_block => val[0]} 468 } 255 469 | type_identifier untyped_multiple_attr_object_block 470 { 471 result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]} 472 } 256 473 257 474 untyped_multiple_attr_object_block: multiple_attr_object_block_head keyed_objects SYM_END_DBLOCK 475 { 476 result = {:multiple_attr_object_block_head => val[0], :keyed_objects => val[1]} 477 } 258 478 259 479 multiple_attr_object_block_head: SYM_START_DBLOCK 260 { 480 { 261 481 @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}") 482 result = val[0] 262 483 } 263 484 264 485 keyed_objects: keyed_object 486 { 487 result = Array[val[0]] 488 } 265 489 | keyed_objects keyed_object 490 { 491 result = (val[0] << val[1]) 492 } 266 493 267 494 keyed_object: object_key SYM_EQ object_block 268 495 { 269 496 @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}") 497 result = {:object_key => val[0], :object_block => val[1]} 270 498 } 271 499 … … 273 501 { 274 502 @@log.info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}") 503 result = val[1] 275 504 } 276 505 277 506 single_attr_object_block: untyped_single_attr_object_block 507 { 508 result = {:untyped_single_attr_object_block => val[0]} 509 } 278 510 | type_identifier untyped_single_attr_object_block 511 { 512 result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]} 513 } 514 279 515 untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # <> 516 { 517 @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}") 518 result = {:single_attr_object_complex_head => val[0]} 519 } 280 520 | single_attr_object_complex_head attr_vals SYM_END_DBLOCK 521 { 522 @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]}, attr_vals = #{val[1]} at #{@filename}:#{@lineno}") 523 result = {:single_attr_object_complex_head => val[0], :attr_vals => val[1]} 524 } 281 525 single_attr_object_complex_head: SYM_START_DBLOCK 282 526 primitive_object_block: untyped_primitive_object_block 527 { 528 @@log.info("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}") 529 result = {:untyped_primitive_object_block => val[0]} 530 } 283 531 | type_identifier untyped_primitive_object_block 532 { 533 @@log.info("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}") 534 result = {:type_identifier => val[0], :untyped_primitive_object_block => val[1]} 535 } 284 536 untyped_primitive_object_block: SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK 285 537 { 286 @@log.info("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[2]}> at #{@filename}:#{@lineno}") 538 @@log.info("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}") 539 result = val[1] 287 540 } 288 541 primitive_object_value: simple_value 542 { 543 result = val[0] 544 } 289 545 | simple_list_value 546 { 547 result = val[0] 548 } 290 549 | simple_interval_value 550 { 551 result = val[0] 552 } 291 553 | term_code 554 { 555 result = val[0] 556 } 292 557 | term_code_list_value 558 { 559 result = val[0] 560 } 293 561 simple_value: string_value 294 562 { 295 563 @@log.info("string_value: #{val[0]} at #{@filename}:#{@lineno}") 564 result = val[0] 296 565 } 297 566 | integer_value 298 567 { 299 568 @@log.info("integer_value: #{val[0]} at #{@filename}:#{@lineno}") 569 result = val[0] 300 570 } 301 571 | real_value 302 572 { 303 573 @@log.info("real_value: #{val[0]} at #{@filename}:#{@lineno}") 574 result = val[0] 304 575 } 305 576 | boolean_value 306 577 { 307 578 @@log.info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}") 579 result = val[0] 308 580 } 309 581 | character_value 310 582 { 311 583 @@log.info("character_value: #{val[0]} at #{@filename}:#{@lineno}") 584 result = val[0] 312 585 } 313 586 | date_value 314 587 { 315 588 @@log.info("date_value: #{val[0]} at #{@filename}:#{@lineno}") 589 result = val[0] 316 590 } 317 591 | time_value 318 592 { 319 593 @@log.info("time_value: #{val[0]} at #{@filename}:#{@lineno}") 594 result = val[0] 320 595 } 321 596 | date_time_value 322 597 { 323 598 @@log.info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}") 599 result = val[0] 324 600 } 325 601 | duration_value 326 602 { 327 603 @@log.info("duration_value: #{val[0]} at #{@filename}:#{@lineno}") 604 result = val[0] 328 605 } 329 606 | uri_value 330 607 { 331 608 @@log.info("uri_value: #{val[0]} at #{@filename}:#{@lineno}") 332 } 609 result = val[0] 610 } 611 333 612 simple_list_value: string_list_value 334 613 | integer_list_value … … 351 630 { 352 631 @@log.info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}") 632 result = val[0] 353 633 } 354 634 | V_GENERIC_TYPE_IDENTIFIER 355 635 { 356 636 @@log.info("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}") 637 result = val[0] 357 638 } 358 639 … … 360 641 { 361 642 @@log.info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}") 643 result = val[0] 362 644 } 363 645 … … 367 649 368 650 integer_value: V_INTEGER 651 { 652 begin 653 integer = Integer(val[0]) 654 rescue 655 raise 656 end 657 result = integer 658 } 369 659 | Plus_code V_INTEGER 660 { 661 begin 662 integer = Integer(val[0]) 663 rescue 664 raise 665 end 666 result = integer 667 } 370 668 | Minus_code V_INTEGER 669 { 670 begin 671 integer = Integer(val[0]) 672 rescue 673 raise 674 end 675 result = - integer 676 } 371 677 ### | '+' V_INTEGER 372 678 ### | '-' V_INTEGER … … 387 693 388 694 real_value: V_REAL 695 { 696 begin 697 real = Float(val[0]) 698 rescue 699 raise 700 end 701 result = real 702 } 389 703 | Plus_code V_REAL 704 { 705 begin 706 real = Float(val[1]) 707 rescue 708 raise 709 end 710 result = real 711 } 390 712 | Minus_code V_REAL 391 # | '+' V_REAL 392 # | '-' V_REAL 713 { 714 begin 715 real = Float(val[1]) 716 rescue 717 raise 718 end 719 result = - real 720 } 393 721 394 722 real_list_value: real_value Comma_code real_value … … 408 736 409 737 boolean_value: SYM_TRUE 738 { 739 result = true 740 } 410 741 | SYM_FALSE 742 { 743 result = false 744 } 411 745 412 746 boolean_list_value: boolean_value Comma_code boolean_value … … 471 805 { 472 806 @@log.info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}") 807 result = val[0] 473 808 } 474 809 … … 490 825 { 491 826 @@log.info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}") 827 result = val[0] 492 828 } 493 829 … … 499 835 { 500 836 @@log.info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}") 837 result = val[0] 501 838 } 502 839 … … 581 918 582 919 c_existence: #-- default to 1..1 583 | SYM_EXISTENCE SYM_MATCHES SYM_START_CBLOCK existence_spec SYM_END_CBLOCK 920 { 921 result = Range.new(1,1) 922 } 923 | SYM_EXISTENCE SYM_MATCHES SYM_START_CBLOCK existence_spec SYM_END_CBLOCK 924 { 925 result = val[3] 926 } 584 927 585 928 existence_spec: V_INTEGER #-- can only be 0 or 1 929 { 930 begin 931 integer = Integer(val[0]) 932 rescue 933 raise 934 end 935 result = integer 936 } 586 937 | V_INTEGER SYM_ELLIPSIS V_INTEGER #-- can only be 0..0, 0..1, 1..1 938 { 939 begin 940 from_integer = Integer(val[0]) 941 to_integer = Integer(val[2]) 942 rescue 943 raise 944 end 945 result = Range.new(from_integer,to_integer) 946 } 587 947 588 948 c_cardinality: SYM_CARDINALITY SYM_MATCHES SYM_START_CBLOCK cardinality_spec SYM_END_CBLOCK 949 { 950 result = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new 951 } 589 952 590 953 cardinality_spec: occurrence_spec … … 603 966 c_occurrences: #-- default to 1..1 604 967 | SYM_OCCURRENCES SYM_MATCHES SYM_START_CBLOCK occurrence_spec SYM_END_CBLOCK 968 { 969 result = val[3] 970 } 605 971 | SYM_OCCURRENCES error 606 972 … … 670 1036 671 1037 c_boolean_spec: SYM_TRUE 1038 { 1039 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true) 1040 } 672 1041 | SYM_FALSE 1042 { 1043 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false) 1044 } 673 1045 | SYM_TRUE Comma_code SYM_FALSE 1046 { 1047 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,:false_valid => false) 1048 } 674 1049 | SYM_FALSE Comma_code SYM_TRUE 1050 { 1051 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false,:false_valid => true) 1052 } 675 1053 676 1054 c_boolean: c_boolean_spec 1055 { 1056 result = val[0] 1057 } 677 1058 | c_boolean_spec Semicolon_code boolean_value 1059 { 1060 raise 'Not implemented yet' 1061 } 678 1062 | c_boolean_spec Semicolon_code error 679 # | c_boolean_spec ';' error 1063 { 1064 raise 'Not implemented yet' 1065 } 680 1066 681 1067 c_ordinal: c_ordinal_spec 682 1068 | c_ordinal_spec Semicolon_code integer_value 683 1069 | c_ordinal_spec Semicolon_code error 684 # | c_ordinal_spec ';' error685 1070 686 1071 c_ordinal_spec: ordinal 687 1072 | c_ordinal_spec Comma_code ordinal 688 # | c_ordinal_spec ',' ordinal689 1073 690 1074 ordinal: integer_value SYM_INTERVAL_DELIM V_QUALIFIED_TERM_CODE_REF … … 722 1106 723 1107 duration_pattern: V_ISO8601_DURATION_CONSTRAINT_PATTERN 1108 { 1109 result = val[0] 1110 } 724 1111 725 1112 … … 731 1118 require 'lib/util.rb' 732 1119 require 'lib/scanner.rb' 733 require 'lib/model.rb' 1120 require 'rubygems' 1121 require 'am.rb' 734 1122 $DEBUG = true 735 1123 … … 737 1125 738 1126 ---- inner 1127 1128 def assert_at(file,line, message = "") 1129 unless yield 1130 raise "Assertion failed !: #{file}, #{line}: #{message}" 1131 end 1132 end 739 1133 740 1134 @@log = Logger.new('log/parser.log','daily')
Note:
See TracChangeset
for help on using the changeset viewer.