Ignore:
File:
1 edited

Legend:

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

    r20 r26  
    2828
    2929input: archetype EOF
     30  {
     31    result = val[0]
     32  }
    3033  | error
    3134
    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
     35archetype: 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  }
    4058
    4159
    4260arch_identification: arch_head V_ARCHETYPE_ID
     61  {
     62    result = {:arch_head => val[0], :archetype_id => val[1] }
     63  }
    4364  | SYM_ARCHETYPE error
     65  {
     66    raise
     67  }
    4468
    4569arch_head: SYM_ARCHETYPE
     70  {
     71    result = {:arch_meta_data => nil }
     72  }
    4673  | SYM_ARCHETYPE arch_meta_data
     74  {
     75    result = val[1]
     76  }
    4777
    4878arch_meta_data: Left_parenthesis_code arch_meta_data_items Right_parenthesis_code
     79  {
     80    result = {:arch_meta_data => val[1] }
     81  }
    4982
    5083arch_meta_data_items: arch_meta_data_item
     84  {
     85    result = val[0]
     86  }
    5187  | 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
    5392
    5493arch_meta_data_item: SYM_ADL_VERSION SYM_EQ V_VERSION_STRING
     94  {
     95    result = {:adl_version => val[2], :is_controlled => false }
     96  }
    5597  | SYM_IS_CONTROLLED
     98  {
     99    result = {:is_controlled => true }
     100  }
    56101
    57102# Define specialization in which its constraints are narrower than those of the parent.
     
    62107
    63108arch_concept: SYM_CONCEPT V_LOCAL_TERM_CODE_REF
     109  {
     110    result = {:arch_concept => val[1] }
     111  }
    64112  | SYM_CONCEPT error
    65113
     
    69117
    70118arch_language: #-- empty is ok for ADL 1.4 tools
     119  {
     120    result = {:arch_language => nil}
     121  }
    71122    | SYM_LANGUAGE dadl_section
    72123  {
    73     result = {:language => val[1]}
     124    result = {:arch_language => val[1]}
    74125  }
    75126  | SYM_LANGUAGE error
     
    81132arch_description: #-- no meta-data ok
    82133    | 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 
    85139#arch_definition: SYM_DEFINITION V_CADL_TEXT
    86140#  | SYM_DEFINITION error
    87141arch_definition: SYM_DEFINITION cadl_section
     142  {
     143    result = val[1]
     144  }
    88145  | SYM_DEFINITION error
    89146
     
    91148### cADL section
    92149cadl_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  }
    93155  | assertions
     156  {
     157    result = val[0]
     158  }
    94159#  | error
    95160
    96161#c_complex_object: c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body SYM_END_CBLOCK
    97162c_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  }
    98170    | 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
    104179#    | c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body c_invariants SYM_END_CBLOCK
    105180
    106181c_complex_object_head: c_complex_object_id c_occurrences
     182  {
     183    result = {:c_complex_object_id => val[0], :c_occurrences => val[1]}
     184  }
    107185
    108186c_complex_object_id: type_identifier
    109187  {
    110     result = {:c_complex_object_id => {:type_identifier => val[0]}}
     188    result = {:type_identifier => val[0]}
    111189  }
    112190  | type_identifier V_LOCAL_TERM_CODE_REF
    113191  {
    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]}
    115193  }
    116194
    117195c_complex_object_body: c_any #-- used to indicate that any value of a type is ok
    118196  | c_attributes
     197  {
     198    result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => val[0])
     199  }
    119200
    120201
     
    122203
    123204c_object: v_c_domain_type
     205  {
     206    result = val[0]
     207  }
    124208  | c_complex_object
     209  {
     210    result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new
     211  }
    125212  | archetype_internal_ref
     213  {
     214    result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new
     215  }
    126216  | archetype_slot
     217  {
     218    result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new
     219  }
    127220  | constraint_ref
     221  {
     222    result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new
     223  }
    128224  | c_code_phrase
     225  {
     226    result = val[0]
     227  }
    129228  | c_ordinal
     229  {
     230    result = val[0]
     231  }
    130232  | c_primitive_object
     233  {
     234    result = val[0]
     235  }
    131236#  | v_c_domain_type
    132237#  | V_C_DOMAIN_TYPE
     
    141246
    142247v_c_domain_type: START_V_C_DOMAIN_TYPE_BLOCK dadl_section END_V_C_DOMAIN_TYPE_BLOCK
     248  {
     249    result = val[1]
     250  }
    143251
    144252# 'archetype_internal_ref' is a node that refers to a previously defined object node in the same archetype.
     
    157265# 'c_primitive_object' is an node representing a constraint on a primitive object type.
    158266c_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  }
    159271
    160272c_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  }
    161277  | 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  }
    162282  | 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  }
    163287  | 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  }
    164292  | 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  }
    165297  | 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  }
    166302  | 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  }
    167307  | 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  }
    168313
    169314c_any: Star_code
     
    173318
    174319c_attributes: c_attribute
     320  {
     321    result = [val[0]]
     322  }
    175323  | c_attributes c_attribute
     324  {
     325    result = (val[0] << val[1])
     326  }
    176327
    177328# 'c_attribute' is a node representing a constraint on an attribute in an object model.
    178329c_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  }
    179336  | 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  }
    180341  | 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  }
    181346
    182347
     
    184349  {
    185350    @@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
    186356  }
    187357  | V_ATTRIBUTE_IDENTIFIER c_existence c_cardinality
    188358  {
     359    assert_at(__FILE__,__LINE__){ val[2].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY) }
    189360    @@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                                                                                )
    190366  }
    191367
    192368c_attr_values: c_object
     369  {
     370    result = Array[val[0]]
     371  }
    193372  | c_attr_values c_object
     373  {
     374    result = (val[0] << val[1])
     375  }
    194376  | c_any # -- to allow a property to have any value
     377  {
     378    result = Array[val[0]]
     379  }
    195380
    196381### c_includes: #-- Empty
     
    220405
    221406arch_ontology: SYM_ONTOLOGY dadl_section
     407  {
     408    dadl_section = val[1]
     409    result = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new
     410  }
    222411  | SYM_ONTOLOGY error
    223412
     
    231420
    232421attr_vals: attr_val
     422  {
     423    result = Array[val[0]]
     424  }
    233425  | attr_vals attr_val
     426  {
     427    result = (val[0] << val[1])
     428  }
    234429  | attr_vals Semicolon_code attr_val
    235 #  | attr_vals ';' attr_val
     430  {
     431    result = (val[0] << val[2])
     432  }
    236433
    237434attr_val: attr_id SYM_EQ object_block
    238435  {
    239436    @@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]}
    240438  }
    241439
     
    243441  {
    244442    @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")
     443    result = val[0]
    245444  }
    246445  | V_ATTRIBUTE_IDENTIFIER error
    247446
    248447object_block: complex_object_block
     448  {
     449    result = val[0]
     450  }
    249451  | primitive_object_block
     452  {
     453    result = val[0]
     454  }
    250455
    251456complex_object_block: single_attr_object_block
     457  {
     458    result = val[0]
     459  }
    252460  | multiple_attr_object_block
     461  {
     462    result = val[0]
     463  }
    253464
    254465multiple_attr_object_block: untyped_multiple_attr_object_block
     466  {
     467    result = {:untyped_multiple_attr_object_block => val[0]}
     468  }
    255469  | type_identifier untyped_multiple_attr_object_block
     470  {
     471    result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]}
     472  }
    256473
    257474untyped_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  }
    258478
    259479multiple_attr_object_block_head: SYM_START_DBLOCK
    260   {
     480  { 
    261481    @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
     482    result = val[0]
    262483  }
    263484
    264485keyed_objects: keyed_object
     486  {
     487    result = Array[val[0]]
     488  }
    265489  | keyed_objects keyed_object
     490  {
     491    result = (val[0] << val[1])
     492  }
    266493
    267494keyed_object: object_key SYM_EQ object_block
    268495  {
    269496    @@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]}
    270498  }
    271499
     
    273501  {
    274502    @@log.info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
     503    result = val[1]
    275504  }
    276505
    277506single_attr_object_block: untyped_single_attr_object_block
     507  {
     508    result = {:untyped_single_attr_object_block => val[0]}
     509  }
    278510  | type_identifier untyped_single_attr_object_block
     511  {
     512    result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]}
     513  }
     514
    279515untyped_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  }
    280520  | 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  }
    281525single_attr_object_complex_head: SYM_START_DBLOCK
    282526primitive_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  }
    283531  | 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  }
    284536untyped_primitive_object_block: SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK
    285537  {
    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]
    287540  }
    288541primitive_object_value: simple_value
     542  {
     543    result = val[0]
     544  }
    289545  | simple_list_value
     546  {
     547    result = val[0]
     548  }
    290549  | simple_interval_value
     550  {
     551    result = val[0]
     552  }
    291553  | term_code
     554  {
     555    result = val[0]
     556  }
    292557  | term_code_list_value
     558  {
     559    result = val[0]
     560  }
    293561simple_value: string_value
    294562  {
    295563    @@log.info("string_value: #{val[0]} at #{@filename}:#{@lineno}")
     564    result = val[0]
    296565  }
    297566  | integer_value
    298567  {
    299568    @@log.info("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
     569    result = val[0]
    300570  }
    301571  | real_value
    302572  {
    303573    @@log.info("real_value: #{val[0]} at #{@filename}:#{@lineno}")
     574    result = val[0]
    304575  }
    305576  | boolean_value
    306577  {
    307578    @@log.info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
     579    result = val[0]
    308580  }
    309581  | character_value
    310582  {
    311583    @@log.info("character_value: #{val[0]} at #{@filename}:#{@lineno}")
     584    result = val[0]
    312585  }
    313586  | date_value
    314587  {
    315588    @@log.info("date_value: #{val[0]} at #{@filename}:#{@lineno}")
     589    result = val[0]
    316590  }
    317591  | time_value
    318592  {
    319593    @@log.info("time_value: #{val[0]} at #{@filename}:#{@lineno}")
     594    result = val[0]
    320595  }
    321596  | date_time_value
    322597  {
    323598    @@log.info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
     599    result = val[0]
    324600  }
    325601  | duration_value
    326602  {
    327603    @@log.info("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
     604    result = val[0]
    328605  }
    329606  | uri_value
    330607  {
    331608    @@log.info("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
    332   }
     609    result = val[0]
     610  }
     611
    333612simple_list_value: string_list_value
    334613  | integer_list_value
     
    351630  {
    352631    @@log.info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
     632    result = val[0]
    353633  }
    354634  | V_GENERIC_TYPE_IDENTIFIER
    355635  {
    356636    @@log.info("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
     637    result = val[0]
    357638  }
    358639
     
    360641  {
    361642    @@log.info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
     643    result = val[0]
    362644  }
    363645
     
    367649
    368650integer_value: V_INTEGER
     651  {
     652    begin
     653      integer = Integer(val[0])
     654    rescue
     655      raise
     656    end
     657    result = integer
     658  }
    369659  | Plus_code V_INTEGER
     660  {
     661    begin
     662      integer = Integer(val[0])
     663    rescue
     664      raise
     665    end
     666    result = integer
     667  }
    370668  | Minus_code V_INTEGER
     669  {
     670    begin
     671      integer = Integer(val[0])
     672    rescue
     673      raise
     674    end
     675    result = - integer
     676  }
    371677###   | '+' V_INTEGER
    372678###   | '-' V_INTEGER
     
    387693
    388694real_value: V_REAL
     695  {
     696    begin
     697      real = Float(val[0])
     698    rescue
     699      raise
     700    end
     701    result = real
     702  }
    389703  | Plus_code V_REAL
     704  {
     705    begin
     706      real = Float(val[1])
     707    rescue
     708      raise
     709    end
     710    result = real
     711  }
    390712  | 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  }
    393721
    394722real_list_value: real_value Comma_code real_value
     
    408736
    409737boolean_value: SYM_TRUE
     738  {
     739    result = true
     740  }
    410741  | SYM_FALSE
     742  {
     743    result = false
     744  }
    411745
    412746boolean_list_value: boolean_value Comma_code boolean_value
     
    471805  {
    472806    @@log.info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
     807    result = val[0]
    473808  }
    474809
     
    490825  {
    491826    @@log.info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
     827    result = val[0]
    492828  }
    493829
     
    499835  {
    500836    @@log.info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
     837    result = val[0]
    501838  }
    502839
     
    581918
    582919c_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  }
    584927
    585928existence_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  }
    586937  | 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  }
    587947
    588948c_cardinality: SYM_CARDINALITY SYM_MATCHES SYM_START_CBLOCK cardinality_spec SYM_END_CBLOCK
     949  {
     950    result = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new
     951  }
    589952
    590953cardinality_spec: occurrence_spec
     
    603966c_occurrences:  #-- default to 1..1
    604967  | SYM_OCCURRENCES SYM_MATCHES SYM_START_CBLOCK occurrence_spec SYM_END_CBLOCK
     968  {
     969    result = val[3]
     970  }
    605971  | SYM_OCCURRENCES error
    606972
     
    6701036
    6711037c_boolean_spec: SYM_TRUE
     1038  {
     1039    result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true)
     1040  }
    6721041  | SYM_FALSE
     1042  {
     1043    result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false)
     1044  }
    6731045  | 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  }
    6741049  | 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  }
    6751053
    6761054c_boolean: c_boolean_spec
     1055  {
     1056    result = val[0]
     1057  }
    6771058  | c_boolean_spec Semicolon_code boolean_value
     1059  {
     1060    raise 'Not implemented yet'
     1061  }
    6781062  | c_boolean_spec Semicolon_code error
    679 #  | c_boolean_spec ';' error
     1063  {
     1064    raise 'Not implemented yet'
     1065  }
    6801066
    6811067c_ordinal: c_ordinal_spec
    6821068  | c_ordinal_spec Semicolon_code integer_value
    6831069  | c_ordinal_spec Semicolon_code error
    684 #  | c_ordinal_spec ';' error
    6851070
    6861071c_ordinal_spec: ordinal
    6871072  | c_ordinal_spec Comma_code ordinal
    688 #  | c_ordinal_spec ',' ordinal
    6891073
    6901074ordinal: integer_value SYM_INTERVAL_DELIM V_QUALIFIED_TERM_CODE_REF
     
    7221106
    7231107duration_pattern: V_ISO8601_DURATION_CONSTRAINT_PATTERN
     1108  {
     1109    result = val[0]
     1110  }
    7241111
    7251112
     
    7311118require 'lib/util.rb'
    7321119require 'lib/scanner.rb'
    733 require 'lib/model.rb'
     1120require 'rubygems'
     1121require 'am.rb'
    7341122$DEBUG = true
    7351123
     
    7371125
    7381126---- inner
     1127
     1128def assert_at(file,line, message = "")
     1129  unless yield
     1130    raise "Assertion failed !: #{file}, #{line}: #{message}"
     1131  end
     1132end
    7391133
    7401134@@log = Logger.new('log/parser.log','daily')
Note: See TracChangeset for help on using the changeset viewer.