[4] | 1 |
|
---|
| 2 | class OpenEHR::ADL::Parser
|
---|
| 3 |
|
---|
| 4 | #options omit_action_call
|
---|
| 5 |
|
---|
| 6 | prechigh
|
---|
| 7 |
|
---|
| 8 | nonassoc UMINUS UPLUS
|
---|
| 9 | left '*' '/'
|
---|
| 10 | left '+' '-'
|
---|
| 11 |
|
---|
| 12 | nonassoc SYM_EQ
|
---|
| 13 | nonassoc SYM_NE
|
---|
| 14 | nonassoc SYM_LT
|
---|
| 15 | nonassoc SYM_START_DBLOCK
|
---|
| 16 | nonassoc SYM_START_CBLOCK
|
---|
| 17 | nonassoc SYM_GT
|
---|
| 18 | nonassoc SYM_END_CBLOCK
|
---|
| 19 | nonassoc SYM_END_DBLOCK
|
---|
| 20 | nonassoc SYM_LE
|
---|
| 21 | nonassoc SYM_GE
|
---|
| 22 |
|
---|
| 23 | preclow
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | rule
|
---|
| 27 | ### http://svn.openehr.org/ref_impl_eiffel/TRUNK/components/adl_parser/src/syntax/adl/parser/adl_validator.y
|
---|
| 28 |
|
---|
| 29 | input: archetype EOF
|
---|
[21] | 30 | {
|
---|
| 31 | result = val[0]
|
---|
| 32 | }
|
---|
[4] | 33 | | error
|
---|
| 34 |
|
---|
[21] | 35 | archetype: arch_identification arch_specialisation arch_concept arch_language arch_description arch_definition arch_invariant arch_ontology
|
---|
| 36 | {
|
---|
[22] | 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 |
|
---|
[26] | 41 | archetype_id = val[0][:archetype_id]
|
---|
[257] | 42 | parent_archtype_id = val[1][:parent_archtype_id] if val[1]
|
---|
[26] | 43 | adl_version = val[0][:arch_head][:arch_meta_data][:adl_version]
|
---|
| 44 | concept = val[2]
|
---|
| 45 | language = val[3][:arch_language]
|
---|
| 46 | archetype = OpenEHR::AM::Archetype::ARCHETYPE.create(
|
---|
| 47 | :archetype_id => archetype_id,
|
---|
[257] | 48 | :parent_archtype_id => parent_archtype_id,
|
---|
[26] | 49 | :adl_version => adl_version,
|
---|
| 50 | :concept => concept,
|
---|
| 51 | :description => val[4],
|
---|
| 52 | :definition => val[5],
|
---|
| 53 | :ontology => val[7]
|
---|
| 54 | ) do |archetype|
|
---|
| 55 | archetype.original_language = language
|
---|
| 56 | end
|
---|
| 57 | @@log.info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
|
---|
| 58 | result = archetype
|
---|
[21] | 59 | }
|
---|
[4] | 60 |
|
---|
| 61 |
|
---|
| 62 | arch_identification: arch_head V_ARCHETYPE_ID
|
---|
[24] | 63 | {
|
---|
| 64 | result = {:arch_head => val[0], :archetype_id => val[1] }
|
---|
| 65 | }
|
---|
[4] | 66 | | SYM_ARCHETYPE error
|
---|
[24] | 67 | {
|
---|
| 68 | raise
|
---|
| 69 | }
|
---|
[4] | 70 |
|
---|
| 71 | arch_head: SYM_ARCHETYPE
|
---|
[24] | 72 | {
|
---|
| 73 | result = {:arch_meta_data => nil }
|
---|
| 74 | }
|
---|
[4] | 75 | | SYM_ARCHETYPE arch_meta_data
|
---|
[24] | 76 | {
|
---|
[26] | 77 | result = val[1]
|
---|
[24] | 78 | }
|
---|
[4] | 79 |
|
---|
| 80 | arch_meta_data: Left_parenthesis_code arch_meta_data_items Right_parenthesis_code
|
---|
[24] | 81 | {
|
---|
[26] | 82 | result = {:arch_meta_data => val[1] }
|
---|
[24] | 83 | }
|
---|
[4] | 84 |
|
---|
| 85 | arch_meta_data_items: arch_meta_data_item
|
---|
[24] | 86 | {
|
---|
[26] | 87 | result = val[0]
|
---|
[24] | 88 | }
|
---|
[19] | 89 | | arch_meta_data_items Semicolon_code arch_meta_data_item
|
---|
[24] | 90 | {
|
---|
[26] | 91 | result = val[0].merge(val[2])
|
---|
[24] | 92 | }
|
---|
[4] | 93 |
|
---|
[24] | 94 |
|
---|
[4] | 95 | arch_meta_data_item: SYM_ADL_VERSION SYM_EQ V_VERSION_STRING
|
---|
[24] | 96 | {
|
---|
[26] | 97 | result = {:adl_version => val[2], :is_controlled => false }
|
---|
[24] | 98 | }
|
---|
[4] | 99 | | SYM_IS_CONTROLLED
|
---|
[24] | 100 | {
|
---|
[26] | 101 | result = {:is_controlled => true }
|
---|
[24] | 102 | }
|
---|
[4] | 103 |
|
---|
| 104 | # Define specialization in which its constraints are narrower than those of the parent.
|
---|
| 105 | # Any data created via the use of the specialized archetype shall be conformant both to it and its parent.
|
---|
| 106 | arch_specialisation: #-- empty is ok
|
---|
| 107 | | SYM_SPECIALIZE V_ARCHETYPE_ID
|
---|
[257] | 108 | {
|
---|
| 109 | result = {:parent_archtype_id => val[1]}
|
---|
| 110 | }
|
---|
[4] | 111 | | SYM_SPECIALIZE error
|
---|
| 112 |
|
---|
| 113 | arch_concept: SYM_CONCEPT V_LOCAL_TERM_CODE_REF
|
---|
[26] | 114 | {
|
---|
| 115 | result = {:arch_concept => val[1] }
|
---|
| 116 | }
|
---|
[4] | 117 | | SYM_CONCEPT error
|
---|
| 118 |
|
---|
| 119 | #arch_language: #-- empty is ok for ADL 1.4 tools
|
---|
| 120 | # | SYM_LANGUAGE V_DADL_TEXT
|
---|
| 121 | # | SYM_LANGUAGE error
|
---|
| 122 |
|
---|
| 123 | arch_language: #-- empty is ok for ADL 1.4 tools
|
---|
[26] | 124 | {
|
---|
| 125 | result = {:arch_language => nil}
|
---|
| 126 | }
|
---|
[4] | 127 | | SYM_LANGUAGE dadl_section
|
---|
[16] | 128 | {
|
---|
[26] | 129 | result = {:arch_language => val[1]}
|
---|
[16] | 130 | }
|
---|
| 131 | | SYM_LANGUAGE error
|
---|
[4] | 132 |
|
---|
| 133 | #arch_description: #-- no meta-data ok
|
---|
| 134 | # | SYM_DESCRIPTION V_DADL_TEXT
|
---|
| 135 | # | SYM_DESCRIPTION error
|
---|
| 136 |
|
---|
| 137 | arch_description: #-- no meta-data ok
|
---|
| 138 | | SYM_DESCRIPTION dadl_section
|
---|
[21] | 139 | {
|
---|
| 140 | result = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new(:details => val[1])
|
---|
| 141 | }
|
---|
| 142 | | SYM_DESCRIPTION error
|
---|
| 143 |
|
---|
[4] | 144 | #arch_definition: SYM_DEFINITION V_CADL_TEXT
|
---|
| 145 | # | SYM_DEFINITION error
|
---|
| 146 | arch_definition: SYM_DEFINITION cadl_section
|
---|
[21] | 147 | {
|
---|
| 148 | result = val[1]
|
---|
| 149 | }
|
---|
[4] | 150 | | SYM_DEFINITION error
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | ### cADL section
|
---|
| 154 | cadl_section: c_complex_object
|
---|
[35] | 155 | {
|
---|
[22] | 156 | assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT)}
|
---|
[23] | 157 | @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[21] | 158 | result = val[0]
|
---|
| 159 | }
|
---|
[4] | 160 | | assertions
|
---|
[23] | 161 | {
|
---|
| 162 | result = val[0]
|
---|
| 163 | }
|
---|
[4] | 164 | # | error
|
---|
| 165 |
|
---|
| 166 | #c_complex_object: c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body SYM_END_CBLOCK
|
---|
[32] | 167 | c_complex_object: c_complx_object_head SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi
|
---|
[21] | 168 | {
|
---|
[23] | 169 | result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
|
---|
| 170 | c_complex_object.node_id = val[0][:c_complex_object_id][:local_term_code_ref]
|
---|
| 171 | c_complex_object.rm_type_name = val[0][:c_complex_object_id][:type_identifier]
|
---|
| 172 | c_complex_object.occurrences = val[0][:c_occurrences]
|
---|
| 173 | end
|
---|
[21] | 174 | }
|
---|
[4] | 175 | | c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body SYM_END_CBLOCK
|
---|
[21] | 176 | {
|
---|
[23] | 177 | result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
|
---|
| 178 | c_complex_object.node_id = val[0][:c_complex_object_id][:local_term_code_ref]
|
---|
| 179 | c_complex_object.rm_type_name = val[0][:c_complex_object_id][:type_identifier]
|
---|
| 180 | c_complex_object.occurrences = val[0][:c_occurrences]
|
---|
| 181 | end
|
---|
[21] | 182 | }
|
---|
| 183 | # | c_complex_object_head error SYM_END_CBLOCK
|
---|
[4] | 184 | # | c_complex_object_head SYM_MATCHES SYM_START_CBLOCK c_complex_object_body c_invariants SYM_END_CBLOCK
|
---|
| 185 |
|
---|
| 186 | c_complex_object_head: c_complex_object_id c_occurrences
|
---|
[23] | 187 | {
|
---|
| 188 | result = {:c_complex_object_id => val[0], :c_occurrences => val[1]}
|
---|
| 189 | }
|
---|
[4] | 190 |
|
---|
| 191 | c_complex_object_id: type_identifier
|
---|
[16] | 192 | {
|
---|
[23] | 193 | result = {:type_identifier => val[0]}
|
---|
[16] | 194 | }
|
---|
[4] | 195 | | type_identifier V_LOCAL_TERM_CODE_REF
|
---|
[16] | 196 | {
|
---|
[23] | 197 | result = {:type_identifier => val[0], :local_term_code_ref => val[1]}
|
---|
[16] | 198 | }
|
---|
[4] | 199 |
|
---|
| 200 | c_complex_object_body: c_any #-- used to indicate that any value of a type is ok
|
---|
| 201 | | c_attributes
|
---|
[22] | 202 | {
|
---|
| 203 | result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => val[0])
|
---|
| 204 | }
|
---|
[4] | 205 |
|
---|
| 206 |
|
---|
| 207 | #------------------------- node types -----------------------
|
---|
| 208 |
|
---|
[19] | 209 | c_object: v_c_domain_type
|
---|
[32] | 210 | {
|
---|
[22] | 211 | result = val[0]
|
---|
| 212 | }
|
---|
[19] | 213 | | c_complex_object
|
---|
[32] | 214 | {
|
---|
| 215 | @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")
|
---|
| 216 | result = val[0]
|
---|
[22] | 217 | }
|
---|
[4] | 218 | | archetype_internal_ref
|
---|
[32] | 219 | {
|
---|
| 220 | result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.create do |archetype_internal_ref|
|
---|
| 221 | archetype_internal_ref.target_path = val[0][:absolute_path]
|
---|
| 222 | archetype_internal_ref.rm_type_name = val[0][:type_identifier]
|
---|
| 223 | archetype_internal_ref.occurrences = val[0][:c_occurrences]
|
---|
| 224 | end
|
---|
[22] | 225 | }
|
---|
[4] | 226 | | archetype_slot
|
---|
[32] | 227 | {
|
---|
| 228 | result = val[0]
|
---|
[22] | 229 | }
|
---|
[4] | 230 | | constraint_ref
|
---|
[32] | 231 | {
|
---|
| 232 | result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.create do |constraint_ref|
|
---|
| 233 | constraint_ref.reference = val[0]
|
---|
| 234 | end
|
---|
[22] | 235 | }
|
---|
[4] | 236 | | c_code_phrase
|
---|
[32] | 237 | {
|
---|
[22] | 238 | result = val[0]
|
---|
| 239 | }
|
---|
[4] | 240 | | c_ordinal
|
---|
[32] | 241 | {
|
---|
[22] | 242 | result = val[0]
|
---|
| 243 | }
|
---|
[4] | 244 | | c_primitive_object
|
---|
[32] | 245 | {
|
---|
[22] | 246 | result = val[0]
|
---|
| 247 | }
|
---|
[19] | 248 | # | v_c_domain_type
|
---|
[14] | 249 | # | V_C_DOMAIN_TYPE
|
---|
| 250 | # this is an attempt to match a dADL section inside cADL. It will
|
---|
| 251 | # probably never work 100% properly since there can be '>' inside "||"
|
---|
| 252 | # ranges, and also strings containing any character, e.g. units string
|
---|
| 253 | # contining "{}" chars. The real solution is to use the dADL parser on
|
---|
| 254 | # the buffer from the current point on and be able to fast-forward the
|
---|
| 255 | # cursor to the last character matched by the dADL scanner
|
---|
[4] | 256 | | ERR_C_DOMAIN_TYPE
|
---|
| 257 | | error
|
---|
| 258 |
|
---|
[16] | 259 | v_c_domain_type: START_V_C_DOMAIN_TYPE_BLOCK dadl_section END_V_C_DOMAIN_TYPE_BLOCK
|
---|
[23] | 260 | {
|
---|
| 261 | result = val[1]
|
---|
| 262 | }
|
---|
[14] | 263 |
|
---|
[4] | 264 | # 'archetype_internal_ref' is a node that refers to a previously defined object node in the same archetype.
|
---|
| 265 | archetype_internal_ref: SYM_USE_NODE type_identifier c_occurrences absolute_path
|
---|
[32] | 266 | {
|
---|
| 267 | result = {:type_identifier => val[1], :c_occurrences => val[2], :absolute_path => val[3] }
|
---|
| 268 | }
|
---|
[4] | 269 | | SYM_USE_NODE type_identifier error
|
---|
| 270 |
|
---|
| 271 | # 'archetype_slot' is a node whose statements define a constraint that determines which other archetypes may appear at that point in the current archetype.
|
---|
| 272 | archetype_slot: c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK c_includes c_excludes SYM_END_CBLOCK
|
---|
[32] | 273 | {
|
---|
| 274 | result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.create do |archetype_slot|
|
---|
| 275 | archetype_slot.includes = val[3]
|
---|
| 276 | archetype_slot.excludes = val[4]
|
---|
| 277 | archetype_slot.rm_type_name = val[0][:c_archetype_slot_id]
|
---|
| 278 | archetype_slot.occurrences = val[0][:c_occurrences]
|
---|
| 279 | end
|
---|
| 280 | }
|
---|
[4] | 281 | c_archetype_slot_head: c_archetype_slot_id c_occurrences
|
---|
[32] | 282 | {
|
---|
| 283 | result = {:c_archetype_slot_id => val[0],:c_occurrences => val[1]}
|
---|
| 284 | }
|
---|
[4] | 285 |
|
---|
| 286 | c_archetype_slot_id: SYM_ALLOW_ARCHETYPE type_identifier
|
---|
[32] | 287 | {
|
---|
| 288 | result = val[1]
|
---|
| 289 | }
|
---|
[4] | 290 | | SYM_ALLOW_ARCHETYPE type_identifier V_LOCAL_TERM_CODE_REF
|
---|
| 291 | | SYM_ALLOW_ARCHETYPE error
|
---|
| 292 |
|
---|
| 293 | # 'c_primitive_object' is an node representing a constraint on a primitive object type.
|
---|
| 294 | c_primitive_object: c_primitive
|
---|
[22] | 295 | {
|
---|
| 296 | assert_at(__FILE__,__LINE__){val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE)}
|
---|
[32] | 297 | result = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.create do |c_primitive_object|
|
---|
| 298 | c_primitive_object.item = val[0]
|
---|
| 299 | end
|
---|
[22] | 300 | }
|
---|
[4] | 301 |
|
---|
| 302 | c_primitive: c_integer
|
---|
[21] | 303 | {
|
---|
[22] | 304 | @@log.info("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[32] | 305 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.create do |c_integer|
|
---|
| 306 | c_integer.list
|
---|
| 307 | c_integer.range
|
---|
| 308 | c_integer.assumed_value
|
---|
| 309 | end
|
---|
[21] | 310 | }
|
---|
[4] | 311 | | c_real
|
---|
[22] | 312 | {
|
---|
| 313 | @@log.info("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
| 314 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new
|
---|
| 315 | }
|
---|
[4] | 316 | | c_date
|
---|
[22] | 317 | {
|
---|
| 318 | @@log.info("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
| 319 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new
|
---|
| 320 | }
|
---|
[4] | 321 | | c_time
|
---|
[22] | 322 | {
|
---|
| 323 | @@log.info("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
| 324 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new
|
---|
| 325 | }
|
---|
[4] | 326 | | c_date_time
|
---|
[22] | 327 | {
|
---|
| 328 | @@log.info("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
| 329 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new
|
---|
| 330 | }
|
---|
[4] | 331 | | c_duration
|
---|
[22] | 332 | {
|
---|
| 333 | @@log.info("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
| 334 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new
|
---|
| 335 | }
|
---|
[4] | 336 | | c_string
|
---|
[22] | 337 | {
|
---|
| 338 | @@log.info("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
| 339 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new
|
---|
| 340 | }
|
---|
[4] | 341 | | c_boolean
|
---|
[22] | 342 | {
|
---|
| 343 | assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN)}
|
---|
| 344 | @@log.info("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
| 345 | result = val[0]
|
---|
| 346 | }
|
---|
[4] | 347 |
|
---|
| 348 | c_any: Star_code
|
---|
| 349 | #c_any: '*'
|
---|
| 350 |
|
---|
| 351 | #---------------- BODY - relationships ----------------
|
---|
| 352 |
|
---|
| 353 | c_attributes: c_attribute
|
---|
[22] | 354 | {
|
---|
| 355 | result = [val[0]]
|
---|
| 356 | }
|
---|
[4] | 357 | | c_attributes c_attribute
|
---|
[22] | 358 | {
|
---|
| 359 | result = (val[0] << val[1])
|
---|
| 360 | }
|
---|
[4] | 361 |
|
---|
| 362 | # 'c_attribute' is a node representing a constraint on an attribute in an object model.
|
---|
| 363 | c_attribute: c_attr_head SYM_MATCHES SYM_START_CBLOCK c_attr_values SYM_END_CBLOCK
|
---|
[22] | 364 | {
|
---|
| 365 | assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
|
---|
| 366 | c_attribute = val[0]
|
---|
| 367 | c_attribute.children = val[3]
|
---|
| 368 | result = c_attribute
|
---|
| 369 | }
|
---|
[4] | 370 | | c_attr_head SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi
|
---|
[22] | 371 | {
|
---|
| 372 | assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
|
---|
| 373 | result = val[0]
|
---|
| 374 | }
|
---|
[4] | 375 | | c_attr_head SYM_MATCHES SYM_START_CBLOCK error SYM_END_CBLOCK
|
---|
[22] | 376 | {
|
---|
| 377 | assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
|
---|
| 378 | result = val[0]
|
---|
| 379 | }
|
---|
[4] | 380 |
|
---|
| 381 |
|
---|
| 382 | c_attr_head: V_ATTRIBUTE_IDENTIFIER c_existence
|
---|
[19] | 383 | {
|
---|
| 384 | @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}")
|
---|
[22] | 385 | result = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new(
|
---|
| 386 | :rm_attribute_name => val[0],
|
---|
| 387 | :existence => val[1]
|
---|
| 388 | )
|
---|
| 389 |
|
---|
[19] | 390 | }
|
---|
[4] | 391 | | V_ATTRIBUTE_IDENTIFIER c_existence c_cardinality
|
---|
[19] | 392 | {
|
---|
[22] | 393 | assert_at(__FILE__,__LINE__){ val[2].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY) }
|
---|
[19] | 394 | @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}")
|
---|
[22] | 395 | result = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new(
|
---|
| 396 | :rm_attribute_name => val[0],
|
---|
| 397 | :existence => val[1],
|
---|
| 398 | :cardinality => val[2]
|
---|
| 399 | )
|
---|
[19] | 400 | }
|
---|
[4] | 401 |
|
---|
| 402 | c_attr_values: c_object
|
---|
[22] | 403 | {
|
---|
| 404 | result = Array[val[0]]
|
---|
| 405 | }
|
---|
[4] | 406 | | c_attr_values c_object
|
---|
[22] | 407 | {
|
---|
| 408 | result = (val[0] << val[1])
|
---|
| 409 | }
|
---|
[4] | 410 | | c_any # -- to allow a property to have any value
|
---|
[22] | 411 | {
|
---|
| 412 | result = Array[val[0]]
|
---|
| 413 | }
|
---|
[4] | 414 |
|
---|
| 415 | ### c_includes: #-- Empty
|
---|
| 416 | ### | SYM_INCLUDE assertions
|
---|
| 417 | c_includes: #-- Empty
|
---|
| 418 | | SYM_INCLUDE invariants
|
---|
[32] | 419 | {
|
---|
| 420 | result = val[1]
|
---|
| 421 | }
|
---|
[4] | 422 |
|
---|
| 423 | ### c_excludes: #-- Empty
|
---|
| 424 | ### | SYM_EXCLUDE assertions
|
---|
| 425 | c_excludes: #-- Empty
|
---|
| 426 | | SYM_EXCLUDE invariants
|
---|
[32] | 427 | {
|
---|
| 428 | result = val[1]
|
---|
| 429 | }
|
---|
[4] | 430 |
|
---|
| 431 | invariants: invariant
|
---|
| 432 | | invariants invariant
|
---|
| 433 |
|
---|
| 434 | invariant: any_identifier ':' boolean_expression
|
---|
| 435 | | boolean_expression
|
---|
| 436 | | any_identifier ':' error
|
---|
| 437 |
|
---|
| 438 | arch_invariant: #-- no invariant ok
|
---|
| 439 | | SYM_INVARIANT V_ASSERTION_TEXT
|
---|
| 440 | | SYM_INVARIANT error
|
---|
| 441 |
|
---|
| 442 | # define all linguistic entries in this part as dADL.
|
---|
| 443 | #arch_ontology: SYM_ONTOLOGY V_DADL_TEXT
|
---|
| 444 | # | SYM_ONTOLOGY error
|
---|
| 445 |
|
---|
| 446 | arch_ontology: SYM_ONTOLOGY dadl_section
|
---|
[22] | 447 | {
|
---|
[26] | 448 | dadl_section = val[1]
|
---|
[22] | 449 | result = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new
|
---|
| 450 | }
|
---|
[4] | 451 | | SYM_ONTOLOGY error
|
---|
| 452 |
|
---|
| 453 |
|
---|
| 454 | ### dADL section
|
---|
| 455 | dadl_section: dadl_input
|
---|
| 456 |
|
---|
| 457 | dadl_input: attr_vals
|
---|
| 458 | | complex_object_block
|
---|
| 459 | # | error
|
---|
| 460 |
|
---|
| 461 | attr_vals: attr_val
|
---|
[23] | 462 | {
|
---|
| 463 | result = Array[val[0]]
|
---|
| 464 | }
|
---|
[4] | 465 | | attr_vals attr_val
|
---|
[23] | 466 | {
|
---|
| 467 | result = (val[0] << val[1])
|
---|
| 468 | }
|
---|
[19] | 469 | | attr_vals Semicolon_code attr_val
|
---|
[23] | 470 | {
|
---|
| 471 | result = (val[0] << val[2])
|
---|
| 472 | }
|
---|
[4] | 473 |
|
---|
| 474 | attr_val: attr_id SYM_EQ object_block
|
---|
[19] | 475 | {
|
---|
[20] | 476 | @@log.info("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
|
---|
[23] | 477 | result = {:attr_id => val[0], :object_block => val[2]}
|
---|
[19] | 478 | }
|
---|
[4] | 479 |
|
---|
| 480 | attr_id: V_ATTRIBUTE_IDENTIFIER
|
---|
[18] | 481 | {
|
---|
[19] | 482 | @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 483 | result = val[0]
|
---|
[18] | 484 | }
|
---|
[4] | 485 | | V_ATTRIBUTE_IDENTIFIER error
|
---|
| 486 |
|
---|
| 487 | object_block: complex_object_block
|
---|
[22] | 488 | {
|
---|
| 489 | result = val[0]
|
---|
| 490 | }
|
---|
[4] | 491 | | primitive_object_block
|
---|
[22] | 492 | {
|
---|
| 493 | result = val[0]
|
---|
| 494 | }
|
---|
[4] | 495 |
|
---|
| 496 | complex_object_block: single_attr_object_block
|
---|
[22] | 497 | {
|
---|
| 498 | result = val[0]
|
---|
| 499 | }
|
---|
[4] | 500 | | multiple_attr_object_block
|
---|
[22] | 501 | {
|
---|
| 502 | result = val[0]
|
---|
| 503 | }
|
---|
[4] | 504 |
|
---|
| 505 | multiple_attr_object_block: untyped_multiple_attr_object_block
|
---|
[22] | 506 | {
|
---|
[23] | 507 | result = {:untyped_multiple_attr_object_block => val[0]}
|
---|
[22] | 508 | }
|
---|
[4] | 509 | | type_identifier untyped_multiple_attr_object_block
|
---|
[22] | 510 | {
|
---|
[23] | 511 | result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]}
|
---|
[22] | 512 | }
|
---|
[4] | 513 |
|
---|
| 514 | untyped_multiple_attr_object_block: multiple_attr_object_block_head keyed_objects SYM_END_DBLOCK
|
---|
[22] | 515 | {
|
---|
[23] | 516 | result = {:multiple_attr_object_block_head => val[0], :keyed_objects => val[1]}
|
---|
[22] | 517 | }
|
---|
[4] | 518 |
|
---|
| 519 | multiple_attr_object_block_head: SYM_START_DBLOCK
|
---|
[22] | 520 | {
|
---|
[20] | 521 | @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 522 | result = val[0]
|
---|
[20] | 523 | }
|
---|
[4] | 524 |
|
---|
| 525 | keyed_objects: keyed_object
|
---|
[23] | 526 | {
|
---|
| 527 | result = Array[val[0]]
|
---|
| 528 | }
|
---|
[4] | 529 | | keyed_objects keyed_object
|
---|
[23] | 530 | {
|
---|
| 531 | result = (val[0] << val[1])
|
---|
| 532 | }
|
---|
[4] | 533 |
|
---|
| 534 | keyed_object: object_key SYM_EQ object_block
|
---|
[20] | 535 | {
|
---|
| 536 | @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
|
---|
[23] | 537 | result = {:object_key => val[0], :object_block => val[1]}
|
---|
[20] | 538 | }
|
---|
[4] | 539 |
|
---|
| 540 | object_key: Left_bracket_code simple_value Right_bracket_code
|
---|
[19] | 541 | {
|
---|
| 542 | @@log.info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
|
---|
[22] | 543 | result = val[1]
|
---|
[19] | 544 | }
|
---|
[4] | 545 |
|
---|
| 546 | single_attr_object_block: untyped_single_attr_object_block
|
---|
[23] | 547 | {
|
---|
| 548 | result = {:untyped_single_attr_object_block => val[0]}
|
---|
| 549 | }
|
---|
[4] | 550 | | type_identifier untyped_single_attr_object_block
|
---|
[23] | 551 | {
|
---|
| 552 | result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]}
|
---|
| 553 | }
|
---|
| 554 |
|
---|
[257] | 555 | untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # >
|
---|
[22] | 556 | {
|
---|
| 557 | @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[23] | 558 | result = {:single_attr_object_complex_head => val[0]}
|
---|
[22] | 559 | }
|
---|
[4] | 560 | | single_attr_object_complex_head attr_vals SYM_END_DBLOCK
|
---|
[22] | 561 | {
|
---|
| 562 | @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]}, attr_vals = #{val[1]} at #{@filename}:#{@lineno}")
|
---|
[23] | 563 | result = {:single_attr_object_complex_head => val[0], :attr_vals => val[1]}
|
---|
[22] | 564 | }
|
---|
[4] | 565 | single_attr_object_complex_head: SYM_START_DBLOCK
|
---|
| 566 | primitive_object_block: untyped_primitive_object_block
|
---|
[22] | 567 | {
|
---|
| 568 | @@log.info("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[23] | 569 | result = {:untyped_primitive_object_block => val[0]}
|
---|
[22] | 570 | }
|
---|
[4] | 571 | | type_identifier untyped_primitive_object_block
|
---|
[22] | 572 | {
|
---|
| 573 | @@log.info("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")
|
---|
[23] | 574 | result = {:type_identifier => val[0], :untyped_primitive_object_block => val[1]}
|
---|
[22] | 575 | }
|
---|
[4] | 576 | untyped_primitive_object_block: SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK
|
---|
[20] | 577 | {
|
---|
[22] | 578 | @@log.info("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}")
|
---|
| 579 | result = val[1]
|
---|
[20] | 580 | }
|
---|
[4] | 581 | primitive_object_value: simple_value
|
---|
[22] | 582 | {
|
---|
| 583 | result = val[0]
|
---|
| 584 | }
|
---|
[4] | 585 | | simple_list_value
|
---|
[22] | 586 | {
|
---|
| 587 | result = val[0]
|
---|
| 588 | }
|
---|
[4] | 589 | | simple_interval_value
|
---|
[22] | 590 | {
|
---|
| 591 | result = val[0]
|
---|
| 592 | }
|
---|
[4] | 593 | | term_code
|
---|
[22] | 594 | {
|
---|
| 595 | result = val[0]
|
---|
| 596 | }
|
---|
[4] | 597 | | term_code_list_value
|
---|
[22] | 598 | {
|
---|
| 599 | result = val[0]
|
---|
| 600 | }
|
---|
[4] | 601 | simple_value: string_value
|
---|
[19] | 602 | {
|
---|
| 603 | @@log.info("string_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 604 | result = val[0]
|
---|
[19] | 605 | }
|
---|
[4] | 606 | | integer_value
|
---|
[19] | 607 | {
|
---|
| 608 | @@log.info("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 609 | result = val[0]
|
---|
[19] | 610 | }
|
---|
[4] | 611 | | real_value
|
---|
[19] | 612 | {
|
---|
| 613 | @@log.info("real_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 614 | result = val[0]
|
---|
[19] | 615 | }
|
---|
[4] | 616 | | boolean_value
|
---|
[19] | 617 | {
|
---|
| 618 | @@log.info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 619 | result = val[0]
|
---|
[19] | 620 | }
|
---|
[4] | 621 | | character_value
|
---|
[19] | 622 | {
|
---|
| 623 | @@log.info("character_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 624 | result = val[0]
|
---|
[19] | 625 | }
|
---|
[4] | 626 | | date_value
|
---|
[19] | 627 | {
|
---|
| 628 | @@log.info("date_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 629 | result = val[0]
|
---|
[19] | 630 | }
|
---|
[4] | 631 | | time_value
|
---|
[19] | 632 | {
|
---|
| 633 | @@log.info("time_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 634 | result = val[0]
|
---|
[19] | 635 | }
|
---|
[4] | 636 | | date_time_value
|
---|
[19] | 637 | {
|
---|
| 638 | @@log.info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 639 | result = val[0]
|
---|
[19] | 640 | }
|
---|
[4] | 641 | | duration_value
|
---|
[19] | 642 | {
|
---|
| 643 | @@log.info("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 644 | result = val[0]
|
---|
[19] | 645 | }
|
---|
[4] | 646 | | uri_value
|
---|
[19] | 647 | {
|
---|
| 648 | @@log.info("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 649 | result = val[0]
|
---|
[19] | 650 | }
|
---|
[22] | 651 |
|
---|
[4] | 652 | simple_list_value: string_list_value
|
---|
| 653 | | integer_list_value
|
---|
| 654 | | real_list_value
|
---|
| 655 | | boolean_list_value
|
---|
| 656 | | character_list_value
|
---|
| 657 | | date_list_value
|
---|
| 658 | | time_list_value
|
---|
| 659 | | date_time_list_value
|
---|
| 660 | | duration_list_value
|
---|
| 661 |
|
---|
| 662 | simple_interval_value: integer_interval_value
|
---|
| 663 | | real_interval_value
|
---|
| 664 | | date_interval_value
|
---|
| 665 | | time_interval_value
|
---|
| 666 | | date_time_interval_value
|
---|
| 667 | | duration_interval_value
|
---|
| 668 |
|
---|
| 669 | type_identifier: V_TYPE_IDENTIFIER
|
---|
[19] | 670 | {
|
---|
| 671 | @@log.info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 672 | result = val[0]
|
---|
[19] | 673 | }
|
---|
[4] | 674 | | V_GENERIC_TYPE_IDENTIFIER
|
---|
[19] | 675 | {
|
---|
| 676 | @@log.info("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 677 | result = val[0]
|
---|
[19] | 678 | }
|
---|
[4] | 679 |
|
---|
| 680 | string_value: V_STRING
|
---|
[18] | 681 | {
|
---|
[19] | 682 | @@log.info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 683 | result = val[0]
|
---|
[18] | 684 | }
|
---|
[4] | 685 |
|
---|
| 686 | string_list_value: V_STRING Comma_code V_STRING
|
---|
| 687 | | string_list_value Comma_code V_STRING
|
---|
| 688 | | V_STRING Comma_code SYM_LIST_CONTINUE
|
---|
| 689 |
|
---|
| 690 | integer_value: V_INTEGER
|
---|
[22] | 691 | {
|
---|
| 692 | begin
|
---|
| 693 | integer = Integer(val[0])
|
---|
| 694 | rescue
|
---|
| 695 | raise
|
---|
| 696 | end
|
---|
| 697 | result = integer
|
---|
| 698 | }
|
---|
[18] | 699 | | Plus_code V_INTEGER
|
---|
[22] | 700 | {
|
---|
| 701 | begin
|
---|
| 702 | integer = Integer(val[0])
|
---|
| 703 | rescue
|
---|
| 704 | raise
|
---|
| 705 | end
|
---|
| 706 | result = integer
|
---|
| 707 | }
|
---|
[18] | 708 | | Minus_code V_INTEGER
|
---|
[22] | 709 | {
|
---|
| 710 | begin
|
---|
| 711 | integer = Integer(val[0])
|
---|
| 712 | rescue
|
---|
| 713 | raise
|
---|
| 714 | end
|
---|
| 715 | result = - integer
|
---|
| 716 | }
|
---|
[18] | 717 | ### | '+' V_INTEGER
|
---|
| 718 | ### | '-' V_INTEGER
|
---|
[4] | 719 |
|
---|
| 720 | integer_list_value: integer_value Comma_code integer_value
|
---|
| 721 | | integer_list_value Comma_code integer_value
|
---|
| 722 | | integer_value Comma_code SYM_LIST_CONTINUE
|
---|
| 723 |
|
---|
| 724 | integer_interval_value: SYM_INTERVAL_DELIM integer_value SYM_ELLIPSIS integer_value SYM_INTERVAL_DELIM
|
---|
| 725 | | SYM_INTERVAL_DELIM SYM_GT integer_value SYM_ELLIPSIS integer_value SYM_INTERVAL_DELIM
|
---|
| 726 | | SYM_INTERVAL_DELIM integer_value SYM_ELLIPSIS SYM_LT integer_value SYM_INTERVAL_DELIM
|
---|
| 727 | | SYM_INTERVAL_DELIM SYM_GT integer_value SYM_ELLIPSIS SYM_LT integer_value SYM_INTERVAL_DELIM
|
---|
| 728 | | SYM_INTERVAL_DELIM SYM_LT integer_value SYM_INTERVAL_DELIM
|
---|
| 729 | | SYM_INTERVAL_DELIM SYM_LE integer_value SYM_INTERVAL_DELIM
|
---|
| 730 | | SYM_INTERVAL_DELIM SYM_GT integer_value SYM_INTERVAL_DELIM
|
---|
| 731 | | SYM_INTERVAL_DELIM SYM_GE integer_value SYM_INTERVAL_DELIM
|
---|
| 732 | | SYM_INTERVAL_DELIM integer_value SYM_INTERVAL_DELIM
|
---|
| 733 |
|
---|
| 734 | real_value: V_REAL
|
---|
[23] | 735 | {
|
---|
| 736 | begin
|
---|
| 737 | real = Float(val[0])
|
---|
| 738 | rescue
|
---|
| 739 | raise
|
---|
| 740 | end
|
---|
| 741 | result = real
|
---|
| 742 | }
|
---|
[18] | 743 | | Plus_code V_REAL
|
---|
[23] | 744 | {
|
---|
| 745 | begin
|
---|
[25] | 746 | real = Float(val[1])
|
---|
[23] | 747 | rescue
|
---|
| 748 | raise
|
---|
| 749 | end
|
---|
| 750 | result = real
|
---|
| 751 | }
|
---|
[18] | 752 | | Minus_code V_REAL
|
---|
[23] | 753 | {
|
---|
| 754 | begin
|
---|
[25] | 755 | real = Float(val[1])
|
---|
[23] | 756 | rescue
|
---|
| 757 | raise
|
---|
| 758 | end
|
---|
| 759 | result = - real
|
---|
| 760 | }
|
---|
[4] | 761 |
|
---|
| 762 | real_list_value: real_value Comma_code real_value
|
---|
| 763 | | real_list_value Comma_code real_value
|
---|
| 764 | | real_value Comma_code SYM_LIST_CONTINUE
|
---|
| 765 |
|
---|
| 766 | real_interval_value: SYM_INTERVAL_DELIM real_value SYM_ELLIPSIS real_value SYM_INTERVAL_DELIM
|
---|
| 767 | | SYM_INTERVAL_DELIM SYM_GT real_value SYM_ELLIPSIS real_value SYM_INTERVAL_DELIM
|
---|
| 768 | | SYM_INTERVAL_DELIM real_value SYM_ELLIPSIS SYM_LT real_value SYM_INTERVAL_DELIM
|
---|
| 769 | | SYM_INTERVAL_DELIM SYM_GT real_value SYM_ELLIPSIS SYM_LT real_value SYM_INTERVAL_DELIM
|
---|
| 770 | | SYM_INTERVAL_DELIM SYM_LT real_value SYM_INTERVAL_DELIM
|
---|
| 771 | | SYM_INTERVAL_DELIM SYM_LE real_value SYM_INTERVAL_DELIM
|
---|
| 772 | | SYM_INTERVAL_DELIM SYM_GT real_value SYM_INTERVAL_DELIM
|
---|
| 773 | | SYM_INTERVAL_DELIM SYM_GE real_value SYM_INTERVAL_DELIM
|
---|
| 774 | | SYM_INTERVAL_DELIM real_value SYM_INTERVAL_DELIM
|
---|
| 775 |
|
---|
| 776 |
|
---|
| 777 | boolean_value: SYM_TRUE
|
---|
[23] | 778 | {
|
---|
| 779 | result = true
|
---|
| 780 | }
|
---|
[4] | 781 | | SYM_FALSE
|
---|
[23] | 782 | {
|
---|
| 783 | result = false
|
---|
| 784 | }
|
---|
[4] | 785 |
|
---|
| 786 | boolean_list_value: boolean_value Comma_code boolean_value
|
---|
| 787 | | boolean_list_value Comma_code boolean_value
|
---|
| 788 | | boolean_value Comma_code SYM_LIST_CONTINUE
|
---|
| 789 |
|
---|
| 790 | character_value: V_CHARACTER
|
---|
| 791 |
|
---|
| 792 | character_list_value: character_value Comma_code character_value
|
---|
| 793 | | character_list_value Comma_code character_value
|
---|
| 794 | | character_value Comma_code SYM_LIST_CONTINUE
|
---|
| 795 |
|
---|
| 796 | date_value: V_ISO8601_EXTENDED_DATE
|
---|
| 797 |
|
---|
| 798 | date_list_value: date_value Comma_code date_value
|
---|
| 799 | | date_list_value Comma_code date_value
|
---|
| 800 | | date_value Comma_code SYM_LIST_CONTINUE
|
---|
| 801 |
|
---|
| 802 | date_interval_value: SYM_INTERVAL_DELIM date_value SYM_ELLIPSIS date_value SYM_INTERVAL_DELIM
|
---|
| 803 | | SYM_INTERVAL_DELIM SYM_GT date_value SYM_ELLIPSIS date_value SYM_INTERVAL_DELIM
|
---|
| 804 | | SYM_INTERVAL_DELIM date_value SYM_ELLIPSIS SYM_LT date_value SYM_INTERVAL_DELIM
|
---|
| 805 | | SYM_INTERVAL_DELIM SYM_GT date_value SYM_ELLIPSIS SYM_LT date_value SYM_INTERVAL_DELIM
|
---|
| 806 | | SYM_INTERVAL_DELIM SYM_LT date_value SYM_INTERVAL_DELIM
|
---|
| 807 | | SYM_INTERVAL_DELIM SYM_LE date_value SYM_INTERVAL_DELIM
|
---|
| 808 | | SYM_INTERVAL_DELIM SYM_GT date_value SYM_INTERVAL_DELIM
|
---|
| 809 | | SYM_INTERVAL_DELIM SYM_GE date_value SYM_INTERVAL_DELIM
|
---|
| 810 | | SYM_INTERVAL_DELIM date_value SYM_INTERVAL_DELIM
|
---|
| 811 |
|
---|
| 812 | time_value: V_ISO8601_EXTENDED_TIME
|
---|
| 813 |
|
---|
| 814 | time_list_value: time_value Comma_code time_value
|
---|
| 815 | | time_list_value Comma_code time_value
|
---|
| 816 | | time_value Comma_code SYM_LIST_CONTINUE
|
---|
| 817 |
|
---|
| 818 | time_interval_value: SYM_INTERVAL_DELIM time_value SYM_ELLIPSIS time_value SYM_INTERVAL_DELIM
|
---|
| 819 | | SYM_INTERVAL_DELIM SYM_GT time_value SYM_ELLIPSIS time_value SYM_INTERVAL_DELIM
|
---|
| 820 | | SYM_INTERVAL_DELIM time_value SYM_ELLIPSIS SYM_LT time_value SYM_INTERVAL_DELIM
|
---|
| 821 | | SYM_INTERVAL_DELIM SYM_GT time_value SYM_ELLIPSIS SYM_LT time_value SYM_INTERVAL_DELIM
|
---|
| 822 | | SYM_INTERVAL_DELIM SYM_LT time_value SYM_INTERVAL_DELIM
|
---|
| 823 | | SYM_INTERVAL_DELIM SYM_LE time_value SYM_INTERVAL_DELIM
|
---|
| 824 | | SYM_INTERVAL_DELIM SYM_GT time_value SYM_INTERVAL_DELIM
|
---|
| 825 | | SYM_INTERVAL_DELIM SYM_GE time_value SYM_INTERVAL_DELIM
|
---|
| 826 | | SYM_INTERVAL_DELIM time_value SYM_INTERVAL_DELIM
|
---|
| 827 |
|
---|
| 828 | date_time_value: V_ISO8601_EXTENDED_DATE_TIME
|
---|
| 829 |
|
---|
| 830 | date_time_list_value: date_time_value Comma_code date_time_value
|
---|
| 831 | | date_time_list_value Comma_code date_time_value
|
---|
| 832 | | date_time_value Comma_code SYM_LIST_CONTINUE
|
---|
| 833 |
|
---|
| 834 | date_time_interval_value: SYM_INTERVAL_DELIM date_time_value SYM_ELLIPSIS date_time_value SYM_INTERVAL_DELIM
|
---|
| 835 | | SYM_INTERVAL_DELIM SYM_GT date_time_value SYM_ELLIPSIS date_time_value SYM_INTERVAL_DELIM
|
---|
| 836 | | SYM_INTERVAL_DELIM date_time_value SYM_ELLIPSIS SYM_LT date_time_value SYM_INTERVAL_DELIM
|
---|
| 837 | | SYM_INTERVAL_DELIM SYM_GT date_time_value SYM_ELLIPSIS SYM_LT date_time_value SYM_INTERVAL_DELIM
|
---|
| 838 | | SYM_INTERVAL_DELIM SYM_LT date_time_value SYM_INTERVAL_DELIM
|
---|
| 839 | | SYM_INTERVAL_DELIM SYM_LE date_time_value SYM_INTERVAL_DELIM
|
---|
| 840 | | SYM_INTERVAL_DELIM SYM_GT date_time_value SYM_INTERVAL_DELIM
|
---|
| 841 | | SYM_INTERVAL_DELIM SYM_GE date_time_value SYM_INTERVAL_DELIM
|
---|
| 842 | | SYM_INTERVAL_DELIM date_time_value SYM_INTERVAL_DELIM
|
---|
| 843 |
|
---|
| 844 | duration_value: V_ISO8601_DURATION
|
---|
[19] | 845 | {
|
---|
| 846 | @@log.info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[22] | 847 | result = val[0]
|
---|
[19] | 848 | }
|
---|
[4] | 849 |
|
---|
| 850 | duration_list_value: duration_value Comma_code duration_value
|
---|
| 851 | | duration_list_value Comma_code duration_value
|
---|
| 852 | | duration_value Comma_code SYM_LIST_CONTINUE
|
---|
| 853 |
|
---|
| 854 | duration_interval_value: SYM_INTERVAL_DELIM duration_value SYM_ELLIPSIS duration_value SYM_INTERVAL_DELIM
|
---|
| 855 | | SYM_INTERVAL_DELIM SYM_GT duration_value SYM_ELLIPSIS duration_value SYM_INTERVAL_DELIM
|
---|
| 856 | | SYM_INTERVAL_DELIM duration_value SYM_ELLIPSIS SYM_LT duration_value SYM_INTERVAL_DELIM
|
---|
| 857 | | SYM_INTERVAL_DELIM SYM_GT duration_value SYM_ELLIPSIS SYM_LT duration_value SYM_INTERVAL_DELIM
|
---|
| 858 | | SYM_INTERVAL_DELIM SYM_LT duration_value SYM_INTERVAL_DELIM
|
---|
| 859 | | SYM_INTERVAL_DELIM SYM_LE duration_value SYM_INTERVAL_DELIM
|
---|
| 860 | | SYM_INTERVAL_DELIM SYM_GT duration_value SYM_INTERVAL_DELIM
|
---|
| 861 | | SYM_INTERVAL_DELIM SYM_GE duration_value SYM_INTERVAL_DELIM
|
---|
| 862 | | SYM_INTERVAL_DELIM duration_value SYM_INTERVAL_DELIM
|
---|
| 863 |
|
---|
| 864 | term_code: V_QUALIFIED_TERM_CODE_REF
|
---|
[20] | 865 | {
|
---|
| 866 | @@log.info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[26] | 867 | result = val[0]
|
---|
[20] | 868 | }
|
---|
[4] | 869 |
|
---|
| 870 | term_code_list_value: term_code Comma_code term_code
|
---|
| 871 | | term_code_list_value Comma_code term_code
|
---|
| 872 | | term_code Comma_code SYM_LIST_CONTINUE
|
---|
| 873 |
|
---|
| 874 | uri_value: V_URI
|
---|
[20] | 875 | {
|
---|
| 876 | @@log.info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
|
---|
[26] | 877 | result = val[0]
|
---|
[20] | 878 | }
|
---|
[4] | 879 |
|
---|
| 880 |
|
---|
| 881 | #---------------------- ASSERTIONS ------------------------
|
---|
| 882 |
|
---|
| 883 | assertions: assertion
|
---|
| 884 | | assertions assertion
|
---|
| 885 |
|
---|
| 886 | assertion: any_identifier ':' boolean_expression
|
---|
| 887 | | boolean_expression
|
---|
| 888 | | any_identifier ':' error
|
---|
| 889 |
|
---|
| 890 | #---------------------- expressions ---------------------
|
---|
| 891 |
|
---|
| 892 | boolean_expression: boolean_leaf
|
---|
| 893 | | boolean_node
|
---|
| 894 |
|
---|
| 895 | boolean_node: SYM_EXISTS absolute_path
|
---|
| 896 | # | absolute_path
|
---|
| 897 | | SYM_EXISTS error
|
---|
| 898 | | relative_path SYM_MATCHES SYM_START_CBLOCK c_primitive SYM_END_CBLOCK
|
---|
| 899 | | relative_path SYM_MATCHES START_REGEXP_BLOCK REGEXP_BODY END_REGEXP_BLOCK # added by akimichi
|
---|
| 900 | | SYM_NOT boolean_leaf
|
---|
| 901 | | arithmetic_expression '=' arithmetic_expression
|
---|
| 902 | | arithmetic_expression SYM_NE arithmetic_expression
|
---|
| 903 | | arithmetic_expression SYM_LT arithmetic_expression
|
---|
| 904 | | arithmetic_expression SYM_GT arithmetic_expression
|
---|
| 905 | | arithmetic_expression SYM_LE arithmetic_expression
|
---|
| 906 | | arithmetic_expression SYM_GE arithmetic_expression
|
---|
| 907 | | boolean_expression SYM_AND boolean_expression
|
---|
| 908 | | boolean_expression SYM_OR boolean_expression
|
---|
| 909 | | boolean_expression SYM_XOR boolean_expression
|
---|
| 910 | | boolean_expression SYM_IMPLIES boolean_expression
|
---|
| 911 |
|
---|
| 912 | boolean_leaf: Left_parenthesis_code boolean_expression Right_parenthesis_code
|
---|
| 913 | | SYM_TRUE
|
---|
| 914 | | SYM_FALSE
|
---|
| 915 |
|
---|
| 916 | arithmetic_expression: arithmetic_leaf
|
---|
| 917 | | arithmetic_node
|
---|
| 918 |
|
---|
| 919 | arithmetic_node: arithmetic_expression '+' arithmetic_leaf
|
---|
| 920 | | arithmetic_expression '-' arithmetic_leaf
|
---|
| 921 | | arithmetic_expression Star_code arithmetic_leaf
|
---|
| 922 | | arithmetic_expression Slash_code arithmetic_leaf
|
---|
| 923 | | arithmetic_expression '^' arithmetic_leaf
|
---|
| 924 |
|
---|
| 925 | arithmetic_leaf: Left_parenthesis_code arithmetic_expression Right_parenthesis_code
|
---|
| 926 | | integer_value
|
---|
| 927 | | real_value
|
---|
| 928 | | absolute_path
|
---|
| 929 |
|
---|
| 930 |
|
---|
| 931 | #--------------- THE FOLLOWING SOURCE TAKEN FROM OG_PATH_VALIDATOR.Y -------------
|
---|
| 932 | #--------------- except to remove movable_path ----------------------------------------------------
|
---|
| 933 |
|
---|
| 934 |
|
---|
| 935 | absolute_path: Slash_code
|
---|
| 936 | | Slash_code relative_path
|
---|
| 937 | # | absolute_path Slash_code relative_path
|
---|
| 938 |
|
---|
| 939 |
|
---|
| 940 |
|
---|
| 941 | relative_path: path_segment
|
---|
| 942 | | relative_path Slash_code path_segment
|
---|
| 943 |
|
---|
| 944 | path_segment: V_ATTRIBUTE_IDENTIFIER V_LOCAL_TERM_CODE_REF
|
---|
[19] | 945 | {
|
---|
| 946 | @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")
|
---|
| 947 | }
|
---|
[4] | 948 | | V_ATTRIBUTE_IDENTIFIER
|
---|
[19] | 949 | {
|
---|
| 950 | @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")
|
---|
| 951 | }
|
---|
[4] | 952 |
|
---|
| 953 |
|
---|
| 954 | #-------------------------------- END SOURCE TAKEN FROM OG_PATH_VALIDATOR.Y ----------------------
|
---|
| 955 |
|
---|
| 956 |
|
---|
| 957 | #---------------- existence, occurrences, cardinality ----------------
|
---|
| 958 |
|
---|
| 959 | c_existence: #-- default to 1..1
|
---|
[22] | 960 | {
|
---|
| 961 | result = Range.new(1,1)
|
---|
| 962 | }
|
---|
| 963 | | SYM_EXISTENCE SYM_MATCHES SYM_START_CBLOCK existence_spec SYM_END_CBLOCK
|
---|
| 964 | {
|
---|
| 965 | result = val[3]
|
---|
| 966 | }
|
---|
[4] | 967 |
|
---|
| 968 | existence_spec: V_INTEGER #-- can only be 0 or 1
|
---|
[22] | 969 | {
|
---|
| 970 | begin
|
---|
| 971 | integer = Integer(val[0])
|
---|
| 972 | rescue
|
---|
| 973 | raise
|
---|
| 974 | end
|
---|
| 975 | result = integer
|
---|
| 976 | }
|
---|
[4] | 977 | | V_INTEGER SYM_ELLIPSIS V_INTEGER #-- can only be 0..0, 0..1, 1..1
|
---|
[22] | 978 | {
|
---|
| 979 | begin
|
---|
| 980 | from_integer = Integer(val[0])
|
---|
| 981 | to_integer = Integer(val[2])
|
---|
| 982 | rescue
|
---|
| 983 | raise
|
---|
| 984 | end
|
---|
| 985 | result = Range.new(from_integer,to_integer)
|
---|
| 986 | }
|
---|
[4] | 987 |
|
---|
| 988 | c_cardinality: SYM_CARDINALITY SYM_MATCHES SYM_START_CBLOCK cardinality_spec SYM_END_CBLOCK
|
---|
[22] | 989 | {
|
---|
| 990 | result = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new
|
---|
| 991 | }
|
---|
[4] | 992 |
|
---|
| 993 | cardinality_spec: occurrence_spec
|
---|
| 994 | | occurrence_spec Semicolon_code SYM_ORDERED
|
---|
| 995 | | occurrence_spec Semicolon_code SYM_UNORDERED
|
---|
| 996 | | occurrence_spec Semicolon_code SYM_UNIQUE
|
---|
| 997 | | occurrence_spec Semicolon_code SYM_ORDERED Semicolon_code SYM_UNIQUE
|
---|
| 998 | | occurrence_spec Semicolon_code SYM_UNORDERED Semicolon_code SYM_UNIQUE
|
---|
| 999 | | occurrence_spec Semicolon_code SYM_UNIQUE Semicolon_code SYM_ORDERED
|
---|
| 1000 | | occurrence_spec Semicolon_code SYM_UNIQUE Semicolon_code SYM_UNORDERED
|
---|
| 1001 |
|
---|
| 1002 | cardinality_limit_value: integer_value
|
---|
[35] | 1003 | {
|
---|
| 1004 | result = val[0]
|
---|
| 1005 | }
|
---|
| 1006 | | Star_code # '*'
|
---|
| 1007 | {
|
---|
| 1008 | result = val[0]
|
---|
| 1009 | }
|
---|
[4] | 1010 |
|
---|
[35] | 1011 |
|
---|
[4] | 1012 | c_occurrences: #-- default to 1..1
|
---|
| 1013 | | SYM_OCCURRENCES SYM_MATCHES SYM_START_CBLOCK occurrence_spec SYM_END_CBLOCK
|
---|
[23] | 1014 | {
|
---|
| 1015 | result = val[3]
|
---|
| 1016 | }
|
---|
[4] | 1017 | | SYM_OCCURRENCES error
|
---|
| 1018 |
|
---|
| 1019 | occurrence_spec: cardinality_limit_value #-- single integer or '*'
|
---|
| 1020 | | V_INTEGER SYM_ELLIPSIS cardinality_limit_value
|
---|
| 1021 |
|
---|
| 1022 | #---------------------- leaf constraint types -----------------------
|
---|
| 1023 |
|
---|
| 1024 | c_integer_spec: integer_value
|
---|
| 1025 | | integer_list_value
|
---|
| 1026 | | integer_interval_value
|
---|
| 1027 |
|
---|
| 1028 | c_integer: c_integer_spec
|
---|
| 1029 | | c_integer_spec Semicolon_code integer_value
|
---|
| 1030 | | c_integer_spec Semicolon_code error
|
---|
| 1031 |
|
---|
| 1032 | c_real_spec: real_value
|
---|
| 1033 | | real_list_value
|
---|
| 1034 | | real_interval_value
|
---|
| 1035 |
|
---|
| 1036 | c_real: c_real_spec
|
---|
| 1037 | | c_real_spec Semicolon_code real_value
|
---|
| 1038 | | c_real_spec Semicolon_code error
|
---|
| 1039 |
|
---|
| 1040 | c_date_constraint: V_ISO8601_DATE_CONSTRAINT_PATTERN
|
---|
| 1041 | | date_value
|
---|
| 1042 | | date_interval_value
|
---|
| 1043 |
|
---|
| 1044 | c_date: c_date_constraint
|
---|
| 1045 | | c_date_constraint Semicolon_code date_value
|
---|
| 1046 | | c_date_constraint Semicolon_code error
|
---|
| 1047 |
|
---|
| 1048 | c_time_constraint: V_ISO8601_TIME_CONSTRAINT_PATTERN
|
---|
| 1049 | | time_value
|
---|
| 1050 | | time_interval_value
|
---|
| 1051 |
|
---|
| 1052 | c_time: c_time_constraint
|
---|
| 1053 | | c_time_constraint Semicolon_code time_value
|
---|
| 1054 | | c_time_constraint Semicolon_code error
|
---|
| 1055 |
|
---|
| 1056 | c_date_time_constraint: V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN
|
---|
| 1057 | | date_time_value
|
---|
| 1058 | | date_time_interval_value
|
---|
| 1059 |
|
---|
| 1060 | c_date_time: c_date_time_constraint
|
---|
| 1061 | | c_date_time_constraint Semicolon_code date_time_value
|
---|
| 1062 | | c_date_time_constraint Semicolon_code error
|
---|
| 1063 |
|
---|
| 1064 | c_duration_constraint: duration_pattern
|
---|
| 1065 | | duration_pattern Slash_code duration_interval_value
|
---|
| 1066 | | duration_value
|
---|
| 1067 | | duration_interval_value
|
---|
| 1068 |
|
---|
| 1069 | c_duration: c_duration_constraint
|
---|
| 1070 | | c_duration_constraint Semicolon_code duration_value
|
---|
| 1071 | | c_duration_constraint Semicolon_code error
|
---|
| 1072 |
|
---|
| 1073 | c_string_spec: V_STRING #-- single value, generates closed list
|
---|
| 1074 | | string_list_value #-- closed list
|
---|
| 1075 | | string_list_value Comma_code SYM_LIST_CONTINUE #-- open list
|
---|
| 1076 | # | string_list_value ',' SYM_LIST_CONTINUE #-- open list
|
---|
| 1077 | # | V_REGEXP #-- regular expression with "//" or "^^" delimiters
|
---|
| 1078 |
|
---|
| 1079 | c_string: c_string_spec
|
---|
| 1080 | | c_string_spec Semicolon_code string_value
|
---|
| 1081 | | c_string_spec Semicolon_code error
|
---|
| 1082 |
|
---|
| 1083 | c_boolean_spec: SYM_TRUE
|
---|
[22] | 1084 | {
|
---|
| 1085 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true)
|
---|
| 1086 | }
|
---|
[4] | 1087 | | SYM_FALSE
|
---|
[22] | 1088 | {
|
---|
| 1089 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false)
|
---|
| 1090 | }
|
---|
[4] | 1091 | | SYM_TRUE Comma_code SYM_FALSE
|
---|
[22] | 1092 | {
|
---|
| 1093 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,:false_valid => false)
|
---|
| 1094 | }
|
---|
[4] | 1095 | | SYM_FALSE Comma_code SYM_TRUE
|
---|
[22] | 1096 | {
|
---|
| 1097 | result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false,:false_valid => true)
|
---|
| 1098 | }
|
---|
[4] | 1099 |
|
---|
| 1100 | c_boolean: c_boolean_spec
|
---|
[22] | 1101 | {
|
---|
| 1102 | result = val[0]
|
---|
| 1103 | }
|
---|
[4] | 1104 | | c_boolean_spec Semicolon_code boolean_value
|
---|
[22] | 1105 | {
|
---|
| 1106 | raise 'Not implemented yet'
|
---|
| 1107 | }
|
---|
[19] | 1108 | | c_boolean_spec Semicolon_code error
|
---|
[22] | 1109 | {
|
---|
| 1110 | raise 'Not implemented yet'
|
---|
| 1111 | }
|
---|
[4] | 1112 |
|
---|
| 1113 | c_ordinal: c_ordinal_spec
|
---|
| 1114 | | c_ordinal_spec Semicolon_code integer_value
|
---|
[19] | 1115 | | c_ordinal_spec Semicolon_code error
|
---|
[4] | 1116 |
|
---|
| 1117 | c_ordinal_spec: ordinal
|
---|
| 1118 | | c_ordinal_spec Comma_code ordinal
|
---|
| 1119 |
|
---|
| 1120 | ordinal: integer_value SYM_INTERVAL_DELIM V_QUALIFIED_TERM_CODE_REF
|
---|
[20] | 1121 | {
|
---|
| 1122 | @in_interval = false
|
---|
| 1123 | @@log.info("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}")
|
---|
| 1124 | }
|
---|
[4] | 1125 |
|
---|
| 1126 | #c_code_phrase: V_TERM_CODE_CONSTRAINT #-- e.g. "[local::at0040, at0041; at0040]"
|
---|
| 1127 | c_code_phrase: term_code_constraint_section #-- e.g. "[local::at0040, at0041; at0040]"
|
---|
[32] | 1128 | {
|
---|
| 1129 | result = val[0]
|
---|
| 1130 | }
|
---|
[4] | 1131 | | V_QUALIFIED_TERM_CODE_REF
|
---|
[32] | 1132 | {
|
---|
| 1133 | result = val[0]
|
---|
| 1134 | }
|
---|
[4] | 1135 |
|
---|
| 1136 | #term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body Right_bracket_code
|
---|
| 1137 | term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT
|
---|
| 1138 | term_code_body: # empty
|
---|
| 1139 | | TERM_CODE
|
---|
| 1140 | | term_code_body TERM_CODE
|
---|
| 1141 | ### term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT
|
---|
| 1142 | ### term_code_body: TERM_CODE
|
---|
| 1143 | ### | term_code_body TERM_CODE
|
---|
| 1144 |
|
---|
| 1145 | # A Constraint_Ref is a proxy for a set of constraints on an object.
|
---|
| 1146 | constraint_ref: V_LOCAL_TERM_CODE_REF #-- e.g. "ac0003"
|
---|
[32] | 1147 | {
|
---|
| 1148 | result = val[0]
|
---|
| 1149 | }
|
---|
[4] | 1150 |
|
---|
| 1151 | any_identifier: type_identifier
|
---|
[32] | 1152 | {
|
---|
| 1153 | result = val[0]
|
---|
| 1154 | }
|
---|
[4] | 1155 | | V_ATTRIBUTE_IDENTIFIER
|
---|
[19] | 1156 | {
|
---|
| 1157 | @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
|
---|
[32] | 1158 | result = val[0]
|
---|
[19] | 1159 | }
|
---|
[4] | 1160 |
|
---|
| 1161 |
|
---|
| 1162 | #----------------- TAKEN FROM DADL_VALIDATOR.Y -------------------
|
---|
| 1163 | #----------------- DO NOT MODIFY -------------------
|
---|
| 1164 | #---------------------- BASIC DATA VALUES -----------------------
|
---|
| 1165 |
|
---|
| 1166 | duration_pattern: V_ISO8601_DURATION_CONSTRAINT_PATTERN
|
---|
[26] | 1167 | {
|
---|
| 1168 | result = val[0]
|
---|
| 1169 | }
|
---|
[4] | 1170 |
|
---|
| 1171 |
|
---|
| 1172 |
|
---|
| 1173 | ---- header
|
---|
| 1174 |
|
---|
[49] | 1175 |
|
---|
[4] | 1176 | $:.unshift File.join(File.dirname(__FILE__))
|
---|
[17] | 1177 | require 'logger'
|
---|
[257] | 1178 | #require 'lib/adl_parser.rb'
|
---|
[21] | 1179 | require 'rubygems'
|
---|
[257] | 1180 | require 'adl_parser.rb'
|
---|
[21] | 1181 | require 'am.rb'
|
---|
[257] | 1182 | require 'rm.rb'
|
---|
[4] | 1183 |
|
---|
| 1184 |
|
---|
[17] | 1185 |
|
---|
[4] | 1186 | ---- inner
|
---|
[17] | 1187 |
|
---|
[22] | 1188 | def assert_at(file,line, message = "")
|
---|
| 1189 | unless yield
|
---|
| 1190 | raise "Assertion failed !: #{file}, #{line}: #{message}"
|
---|
| 1191 | end
|
---|
| 1192 | end
|
---|
| 1193 |
|
---|
[49] | 1194 | if $DEBUG
|
---|
| 1195 | @@log = Logger.new('log/parser.log','daily')
|
---|
| 1196 | @@log.level = Logger::INFO
|
---|
| 1197 | else
|
---|
| 1198 | @@log = Logger.new(STDOUT)
|
---|
| 1199 | @@log.level = Logger::WARN
|
---|
| 1200 | end
|
---|
| 1201 |
|
---|
[17] | 1202 | @@dadl_scanner = OpenEHR::ADL::Scanner::DADL::RootScanner.new
|
---|
[19] | 1203 | @@cadl_scanner = OpenEHR::ADL::Scanner::CADL::RootScanner.new
|
---|
[17] | 1204 |
|
---|
[4] | 1205 | ###----------/* keywords */ ---------------------------------------------
|
---|
| 1206 | @@adl_reserved = {
|
---|
| 1207 | 'archetype' => :SYM_ARCHETYPE,
|
---|
| 1208 | 'adl_version' => :SYM_ADL_VERSION,
|
---|
| 1209 | 'controlled' => :SYM_IS_CONTROLLED,
|
---|
| 1210 | 'specialize' => :SYM_SPECIALIZE,
|
---|
| 1211 | 'concept' => :SYM_CONCEPT,
|
---|
| 1212 | 'language' => :SYM_LANGUAGE,
|
---|
| 1213 | 'description' => :SYM_DESCRIPTION,
|
---|
| 1214 | 'definition' => :SYM_DEFINITION,
|
---|
| 1215 | 'invariant' => :SYM_INVARIANT,
|
---|
| 1216 | 'ontology' => :SYM_ONTOLOGY,
|
---|
| 1217 | 'matches' => :SYM_MATCHES,
|
---|
| 1218 | 'is_in' => :SYM_MATCHES,
|
---|
| 1219 | 'occurrences' => :SYM_OCCURRENCES,
|
---|
| 1220 | 'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE
|
---|
| 1221 | 'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE
|
---|
| 1222 | 'infinity' => :SYM_INFINITY # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY
|
---|
| 1223 | }
|
---|
| 1224 |
|
---|
| 1225 | @@dadl_reserved = {
|
---|
| 1226 | 'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE
|
---|
| 1227 | 'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE
|
---|
| 1228 | 'infinity' => :SYM_INFINITY # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY
|
---|
| 1229 | }
|
---|
| 1230 |
|
---|
| 1231 | @@cadl_reserved = {
|
---|
| 1232 | 'then' => :SYM_THEN, # [Tt][Hh][Ee][Nn]
|
---|
| 1233 | 'else' => :SYM_ELSE, # [Ee][Ll][Ss][Ee]
|
---|
| 1234 | 'and' => :SYM_AND, # [Aa][Nn][Dd]
|
---|
| 1235 | 'or' => :SYM_OR, # [Oo][Rr]
|
---|
| 1236 | 'xor' => :SYM_XOR, # [Xx][Oo][Rr]
|
---|
| 1237 | 'not' => :SYM_NOT, # [Nn][Oo][Tt]
|
---|
| 1238 | 'implies' => :SYM_IMPLIES, # [Ii][Mm][Pp][Ll][Ii][Ee][Ss]
|
---|
| 1239 | 'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE
|
---|
| 1240 | 'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE
|
---|
| 1241 | 'forall' => :SYM_FORALL, # [Ff][Oo][Rr][_][Aa][Ll][Ll]
|
---|
| 1242 | 'exists' => :SYM_EXISTS, # [Ee][Xx][Ii][Ss][Tt][Ss]
|
---|
| 1243 | 'existence' => :SYM_EXISTENCE, # [Ee][Xx][Iu][Ss][Tt][Ee][Nn][Cc][Ee]
|
---|
| 1244 | 'occurrences' => :SYM_OCCURRENCES, # [Oo][Cc][Cc][Uu][Rr][Rr][Ee][Nn][Cc][Ee][Ss]
|
---|
| 1245 | 'cardinality' => :SYM_CARDINALITY, # [Cc][Aa][Rr][Dd][Ii][Nn][Aa][Ll][Ii][Tt][Yy]
|
---|
| 1246 | 'ordered' => :SYM_ORDERED, # [Oo][Rr][Dd][Ee][Rr][Ee][Dd]
|
---|
| 1247 | 'unordered' => :SYM_UNORDERED, # [Uu][Nn][Oo][Rr][Dd][Ee][Rr][Ee][Dd]
|
---|
| 1248 | 'unique' => :SYM_UNIQUE, # [Uu][Nn][Ii][Qq][Uu][Ee]
|
---|
| 1249 | 'matches' => :SYM_MATCHES, # [Mm][Aa][Tt][Cc][Hh][Ee][Ss]
|
---|
| 1250 | 'is_in' => :SYM_MATCHES, # [Ii][Ss][_][Ii][Nn]
|
---|
| 1251 | 'invariant' => :SYM_INVARIANT, # [Ii][Nn][Vv][Aa][Rr][Ii][Aa][Nn][Tt]
|
---|
| 1252 | 'infinity' => :SYM_INFINITY, # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY
|
---|
| 1253 | 'use_node' => :SYM_USE_NODE, # [Uu][Ss][Ee][_][Nn][Oo][Dd][Ee]
|
---|
| 1254 | 'use_archetype' => :SYM_ALLOW_ARCHETYPE, # [Uu][Ss][Ee][_][Aa][Rr][Cc][Hh][Ee][Tt][Yy][Pp][Ee]
|
---|
| 1255 | 'allow_archetype' => :SYM_ALLOW_ARCHETYPE, # [Aa][Ll][Ll][Oo][Ww][_][Aa][Rr][Cc][Hh][Ee][Tt][Yy][Pp][Ee]
|
---|
| 1256 | 'include' => :SYM_INCLUDE, # [Ii][Nn][Cc][Ll][Uu][Dd][Ee]
|
---|
| 1257 | 'exclude' => :SYM_EXCLUDE # [Ee][Xx][Cc][Ll][Uu][Dd][Ee]
|
---|
| 1258 | }
|
---|
| 1259 |
|
---|
| 1260 |
|
---|
| 1261 | ###----------/* Scanner */ -----------------------------------------------
|
---|
| 1262 |
|
---|
| 1263 | def scan
|
---|
| 1264 | until @data.nil? do
|
---|
| 1265 | case @adl_type.last
|
---|
| 1266 | when :adl
|
---|
| 1267 | @data = scan_adl(@data) do |sym, val|
|
---|
| 1268 | yield sym, val
|
---|
| 1269 | end
|
---|
| 1270 | when :dadl
|
---|
| 1271 | @data = scan_dadl(@data) do |sym, val|
|
---|
| 1272 | yield sym, val
|
---|
| 1273 | end
|
---|
| 1274 | when :cadl
|
---|
| 1275 | @data = scan_cadl(@data) do |sym, val|
|
---|
| 1276 | yield sym, val
|
---|
| 1277 | end
|
---|
| 1278 | when :regexp
|
---|
| 1279 | @data = scan_regexp(@data) do |sym, val|
|
---|
| 1280 | yield sym, val
|
---|
| 1281 | end
|
---|
| 1282 | else
|
---|
| 1283 | raise
|
---|
| 1284 | end
|
---|
| 1285 | @data = $' # variable $' receives the string after the match
|
---|
| 1286 | end
|
---|
| 1287 | yield :EOF, nil
|
---|
| 1288 | yield false, '$'
|
---|
| 1289 | end # of scan
|
---|
| 1290 |
|
---|
| 1291 | def scan_adl(data)
|
---|
| 1292 | until data.nil? do
|
---|
| 1293 | case @adl_type.last
|
---|
| 1294 | when :adl
|
---|
| 1295 | # puts "Entering scan_adl"
|
---|
| 1296 | case data
|
---|
| 1297 | when /\A\n/ # carriage return
|
---|
| 1298 | @lineno += 1
|
---|
| 1299 | ;
|
---|
| 1300 | when /\A[ \t\r\f]+/ #just drop it
|
---|
| 1301 | ;
|
---|
| 1302 | when /\A--.*\n/ # single line comment
|
---|
| 1303 | @lineno += 1
|
---|
[19] | 1304 | @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
|
---|
[4] | 1305 | ;
|
---|
| 1306 | when /\Adescription/ # description
|
---|
| 1307 | yield :SYM_DESCRIPTION, :SYM_DESCRIPTION
|
---|
| 1308 | when /\Adefinition/ # definition
|
---|
| 1309 | yield :SYM_DEFINITION, :SYM_DEFINITION
|
---|
| 1310 | # @adl_type.push(:cadl)
|
---|
| 1311 | ###----------/* symbols */ -------------------------------------------------
|
---|
| 1312 | when /\A[A-Z][a-zA-Z0-9_]*/
|
---|
| 1313 | yield :V_TYPE_IDENTIFIER, $&
|
---|
[257] | 1314 | # when /\A[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z0-9]+/ #V_ARCHETYPE_ID
|
---|
| 1315 | when /\A(\w+)-(\w+)-(\w+)\.(\w+)(-\w+)?\.(v[0-9]+)/ #V_ARCHETYPE_ID
|
---|
| 1316 | object_id, rm_originator, rm_name, rm_entity, concept_name, specialisation, version_id = $&, $1, $2, $3, $4, $5, $6
|
---|
| 1317 | archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new(object_id, concept_name, rm_name, rm_entity, rm_originator, specialisation, version_id)
|
---|
| 1318 | # yield :V_ARCHETYPE_ID, $&
|
---|
| 1319 | yield :V_ARCHETYPE_ID, archetype_id
|
---|
[4] | 1320 | when /\A[a-z][a-zA-Z0-9_]*/
|
---|
| 1321 | # word = $&.downcase
|
---|
| 1322 | word = $&
|
---|
| 1323 | if @@adl_reserved[word]
|
---|
[19] | 1324 | @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: @@adl_reserved = #{@@adl_reserved[word]} at #{@filename}:#{@lineno}")
|
---|
[4] | 1325 | yield @@adl_reserved[word], @@adl_reserved[word]
|
---|
| 1326 | elsif #/\A[A-Z][a-zA-Z0-9_]*/
|
---|
[19] | 1327 | @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: V_ATTRIBUTE_IDENTIFIER = #{$&} at #{@filename}:#{@lineno}")
|
---|
[4] | 1328 | yield :V_ATTRIBUTE_IDENTIFIER, $&
|
---|
| 1329 | end
|
---|
| 1330 | when /\A\=/ # =
|
---|
| 1331 | yield :SYM_EQ, :SYM_EQ
|
---|
| 1332 | when /\A\>=/ # >=
|
---|
| 1333 | yield :SYM_GE, :SYM_GE
|
---|
| 1334 | when /\A\<=/ # <=
|
---|
| 1335 | yield :SYM_LE, :SYM_LE
|
---|
| 1336 | when /\A\</ # <
|
---|
| 1337 | if @in_interval
|
---|
| 1338 | # @start_block_received = false
|
---|
| 1339 | yield :SYM_LT, :SYM_LT
|
---|
| 1340 | else
|
---|
| 1341 | # @start_block_received = true
|
---|
| 1342 | @adl_type.push(:dadl)
|
---|
[16] | 1343 | yield :SYM_START_DBLOCK, $&
|
---|
[4] | 1344 | end
|
---|
| 1345 | when /\A\>/ # >
|
---|
| 1346 | if @in_interval
|
---|
| 1347 | yield :SYM_GT, :SYM_GT
|
---|
| 1348 | else
|
---|
| 1349 | adl_type = @adl_type.pop
|
---|
| 1350 | # puts "Escaping #{adl_type}"
|
---|
| 1351 | assert_at(__FILE__,__LINE__){adl_type == :dadl}
|
---|
| 1352 | yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
|
---|
| 1353 | end
|
---|
| 1354 | when /\A\{/ # {
|
---|
| 1355 | @adl_type.push(:cadl)
|
---|
[19] | 1356 | @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
|
---|
[4] | 1357 | yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
|
---|
| 1358 | when /\A\}/ # }
|
---|
| 1359 | adl_type = @adl_type.pop
|
---|
| 1360 | # puts "Escaping #{adl_type}"
|
---|
| 1361 | assert_at(__FILE__,__LINE__){adl_type == :cadl}
|
---|
[19] | 1362 | @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
|
---|
[16] | 1363 | yield :SYM_END_CBLOCK, $&
|
---|
[4] | 1364 | when /\A\-/ # -
|
---|
| 1365 | yield :Minus_code, :Minus_code
|
---|
| 1366 | when /\A\+/ # +
|
---|
| 1367 | yield :Plus_code, :Plus_code
|
---|
| 1368 | when /\A\*/ # *
|
---|
| 1369 | yield :Star_code, :Star_code
|
---|
| 1370 | when /\A\// # /
|
---|
| 1371 | yield :Slash_code, :Slash_code
|
---|
| 1372 | when /\A\^/ # ^
|
---|
| 1373 | yield :Caret_code, :Caret_code
|
---|
| 1374 | when /\A\=/ # =
|
---|
| 1375 | yield :Equal_code, :Equal_code
|
---|
| 1376 | when /\A\.\.\./ # ...
|
---|
| 1377 | yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
|
---|
| 1378 | when /\A\.\./ # ..
|
---|
| 1379 | yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
|
---|
| 1380 | when /\A\./ # .
|
---|
| 1381 | yield :Dot_code, :Dot_code
|
---|
| 1382 | when /\A\;/ # ;
|
---|
| 1383 | yield :Semicolon_code, :Semicolon_code
|
---|
| 1384 | when /\A\,/ # ,
|
---|
| 1385 | yield :Comma_code, :Comma_code
|
---|
| 1386 | when /\A\:/ # :
|
---|
| 1387 | yield :Colon_code, :Colon_code
|
---|
| 1388 | when /\A\!/ # !
|
---|
| 1389 | yield :Exclamation_code, :Exclamation_code
|
---|
| 1390 | when /\A\(/ # (
|
---|
| 1391 | yield :Left_parenthesis_code, :Left_parenthesis_code
|
---|
| 1392 | when /\A\)/ # )
|
---|
| 1393 | yield :Right_parenthesis_code, :Right_parenthesis_code
|
---|
| 1394 | when /\A\$/ # $
|
---|
| 1395 | yield :Dollar_code, :Dollar_code
|
---|
| 1396 | when /\A\?\?/ # ??
|
---|
| 1397 | yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
|
---|
| 1398 | when /\A\?/ # ?
|
---|
| 1399 | yield :Question_mark_code, :Question_mark_code
|
---|
| 1400 | when /\A[0-9]+\.[0-9]+(\.[0-9]+)*/ # ?
|
---|
[257] | 1401 | yield :V_VERSION_STRING, $&
|
---|
[4] | 1402 | when /\A\|/ # |
|
---|
| 1403 | if @in_interval
|
---|
| 1404 | @in_interval = false
|
---|
| 1405 | else
|
---|
| 1406 | @in_interval = true
|
---|
| 1407 | end
|
---|
| 1408 | yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
|
---|
| 1409 | when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/
|
---|
| 1410 | # when /\A\[[a-zA-Z0-9()\._-]+\:\:[a-zA-Z0-9\._-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
|
---|
| 1411 | yield :V_QUALIFIED_TERM_CODE_REF, $&
|
---|
| 1412 | when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF
|
---|
| 1413 | yield :V_LOCAL_TERM_CODE_REF, $&
|
---|
| 1414 | when /\A\[/ # [
|
---|
| 1415 | yield :Left_bracket_code, :Left_bracket_code
|
---|
| 1416 | when /\A\]/ # ]
|
---|
| 1417 | yield :Right_bracket_code, :Right_bracket_code
|
---|
| 1418 |
|
---|
[257] | 1419 | when /\A"([^"]*)"/m #V_STRING
|
---|
| 1420 | yield :V_STRING, $1
|
---|
[4] | 1421 | when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF
|
---|
| 1422 | yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
|
---|
| 1423 | when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE
|
---|
| 1424 | yield :V_LOCAL_CODE, $&
|
---|
| 1425 | when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
|
---|
| 1426 | yield :V_ISO8601_EXTENDED_DATE_TIME, $&
|
---|
| 1427 | when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
|
---|
| 1428 | yield :V_ISO8601_EXTENDED_TIME, $&
|
---|
| 1429 | when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
|
---|
| 1430 | yield :V_ISO8601_EXTENDED_DATE, $&
|
---|
| 1431 | when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER
|
---|
| 1432 | yield :V_GENERIC_TYPE_IDENTIFIER, $&
|
---|
| 1433 | when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER
|
---|
| 1434 | yield :V_INTEGER, $&
|
---|
| 1435 | when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL
|
---|
| 1436 | yield :V_REAL, $&
|
---|
| 1437 | # when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
|
---|
| 1438 | when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
|
---|
| 1439 | yield :V_URI, $&
|
---|
| 1440 | when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
|
---|
| 1441 | yield :V_ISO8601_DURATION, $&
|
---|
| 1442 | when /\A\S/ #UTF8CHAR
|
---|
| 1443 | yield :UTF8CHAR, $&
|
---|
| 1444 | end
|
---|
| 1445 | data = $' # variable $' receives the string after the match
|
---|
| 1446 | when :dadl
|
---|
| 1447 | # puts "Entering scan_dadl"
|
---|
| 1448 | data = scan_dadl(data) do |sym, val|
|
---|
| 1449 | yield sym, val
|
---|
| 1450 | end
|
---|
| 1451 | when :cadl
|
---|
| 1452 | # puts "Entering scan_cadl"
|
---|
| 1453 | data = scan_cadl(data) do |sym, val|
|
---|
| 1454 | yield sym, val
|
---|
| 1455 | end
|
---|
| 1456 | when :regexp
|
---|
| 1457 | # puts "Entering scan_regexp"
|
---|
| 1458 | data = scan_regexp(data) do |sym, val|
|
---|
| 1459 | yield sym, val
|
---|
| 1460 | end
|
---|
| 1461 | when :term_constraint
|
---|
| 1462 | # puts "Entering scan_term_constraint"
|
---|
| 1463 | data = scan_term_constraint(data) do |sym, val|
|
---|
| 1464 | yield sym, val
|
---|
| 1465 | end
|
---|
| 1466 | else
|
---|
| 1467 | raise
|
---|
| 1468 | end
|
---|
| 1469 | end
|
---|
| 1470 | end # scan_adl
|
---|
| 1471 |
|
---|
| 1472 |
|
---|
| 1473 | def scan_cadl(data)
|
---|
| 1474 | until data.nil? do
|
---|
| 1475 | case @adl_type.last
|
---|
| 1476 | when :cadl
|
---|
| 1477 | # puts "Entering scan_cadl"
|
---|
[19] | 1478 | case scanned = @@cadl_scanner.parse(data)
|
---|
| 1479 | when Yaparc::Result::OK
|
---|
| 1480 | if scanned.value[0] == :START_V_C_DOMAIN_TYPE_BLOCK
|
---|
| 1481 | @in_c_domain_type = true
|
---|
| 1482 | @adl_type.push(:dadl)
|
---|
| 1483 | yield scanned.value
|
---|
| 1484 | else
|
---|
| 1485 | yield scanned.value
|
---|
| 1486 | end
|
---|
| 1487 | data = scanned.input
|
---|
| 1488 | end
|
---|
| 1489 |
|
---|
[4] | 1490 | case data
|
---|
| 1491 | when /\A\n/ # carriage return
|
---|
| 1492 | @lineno += 1
|
---|
| 1493 | ;
|
---|
| 1494 | when /\A[ \t\r\f]+/ #just drop it
|
---|
| 1495 | ;
|
---|
| 1496 | when /\A--.*\n/ # single line comment
|
---|
| 1497 | @lineno += 1
|
---|
[19] | 1498 | @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
|
---|
[4] | 1499 | ;
|
---|
| 1500 | ###----------/* symbols */ -------------------------------------------------
|
---|
| 1501 | when /\A\=/ # =
|
---|
| 1502 | yield :SYM_EQ, :SYM_EQ
|
---|
| 1503 | when /\A\>=/ # >=
|
---|
| 1504 | yield :SYM_GE, :SYM_GE
|
---|
| 1505 | when /\A\<=/ # <=
|
---|
| 1506 | yield :SYM_LE, :SYM_LE
|
---|
[19] | 1507 | ### when /\A[A-Z][a-zA-Z0-9_]*[ \n]*\</ # V_C_DOMAIN_TYPE
|
---|
| 1508 | ### @in_c_domain_type = true
|
---|
| 1509 | ### @adl_type.push(:dadl)
|
---|
| 1510 | ### yield :START_V_C_DOMAIN_TYPE_BLOCK, $&
|
---|
[4] | 1511 | when /\A\</ # <
|
---|
| 1512 | if @in_interval
|
---|
| 1513 | yield :SYM_LT, :SYM_LT
|
---|
| 1514 | else
|
---|
| 1515 | @adl_type.push(:dadl)
|
---|
[16] | 1516 | yield :SYM_START_DBLOCK, $&
|
---|
[4] | 1517 | end
|
---|
| 1518 | when /\A\>/ # >
|
---|
| 1519 | if @in_interval
|
---|
| 1520 | yield :SYM_GT, :SYM_GT
|
---|
| 1521 | else
|
---|
| 1522 | adl_type = @adl_type.pop
|
---|
| 1523 | # puts "Escaping #{adl_type}"
|
---|
| 1524 | assert_at(__FILE__,__LINE__){adl_type == :dadl}
|
---|
| 1525 | yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
|
---|
| 1526 | end
|
---|
| 1527 | when /\A\-/ # -
|
---|
| 1528 | yield :Minus_code, :Minus_code
|
---|
| 1529 | when /\A\+/ # +
|
---|
| 1530 | yield :Plus_code, :Plus_code
|
---|
| 1531 | when /\A\*/ # *
|
---|
| 1532 | yield :Star_code, :Star_code
|
---|
| 1533 | when /\A\// # /
|
---|
| 1534 | yield :Slash_code, :Slash_code
|
---|
| 1535 | when /\A\^/ # ^
|
---|
| 1536 | yield :Caret_code, :Caret_code
|
---|
| 1537 | when /\A\.\.\./ # ...
|
---|
| 1538 | yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
|
---|
| 1539 | when /\A\.\./ # ..
|
---|
| 1540 | yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
|
---|
| 1541 | when /\A\./ # .
|
---|
| 1542 | yield :Dot_code, :Dot_code
|
---|
| 1543 | when /\A\;/ # ;
|
---|
| 1544 | yield :Semicolon_code, :Semicolon_code
|
---|
| 1545 | when /\A\,/ # ,
|
---|
| 1546 | yield :Comma_code, :Comma_code
|
---|
| 1547 | when /\A\:/ # :
|
---|
| 1548 | yield :Colon_code, :Colon_code
|
---|
| 1549 | when /\A\!/ # !
|
---|
| 1550 | yield :Exclamation_code, :Exclamation_code
|
---|
| 1551 | when /\A\(/ # (
|
---|
| 1552 | yield :Left_parenthesis_code, :Left_parenthesis_code
|
---|
| 1553 | when /\A\)/ # )
|
---|
| 1554 | yield :Right_parenthesis_code, :Right_parenthesis_code
|
---|
| 1555 | when /\A\{\// #V_REGEXP
|
---|
| 1556 | if @adl_type.last != :regexp
|
---|
| 1557 | @in_regexp = true
|
---|
| 1558 | @adl_type.push(:regexp)
|
---|
| 1559 | yield :START_REGEXP_BLOCK, :START_REGEXP_BLOCK
|
---|
| 1560 | else
|
---|
| 1561 | raise
|
---|
| 1562 | end
|
---|
| 1563 | # yield :V_REGEXP, :V_REGEXP
|
---|
| 1564 | when /\A\{/ # {
|
---|
| 1565 | @adl_type.push(:cadl)
|
---|
[19] | 1566 | @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")
|
---|
[4] | 1567 | yield :SYM_START_CBLOCK, :SYM_START_CBLOCK
|
---|
| 1568 | when /\A\}/ # }
|
---|
| 1569 | adl_type = @adl_type.pop
|
---|
| 1570 | # puts "Escaping #{adl_type}"
|
---|
| 1571 | assert_at(__FILE__,__LINE__){adl_type == :cadl}
|
---|
[19] | 1572 | @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")
|
---|
[4] | 1573 | yield :SYM_END_CBLOCK, :SYM_END_CBLOCK
|
---|
| 1574 | when /\A\$/ # $
|
---|
| 1575 | yield :Dollar_code, :Dollar_code
|
---|
| 1576 | when /\A\?\?/ # ??
|
---|
| 1577 | yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
|
---|
| 1578 | when /\A\?/ # ?
|
---|
| 1579 | yield :Question_mark_code, :Question_mark_code
|
---|
| 1580 | when /\A\|/ # |
|
---|
[20] | 1581 | @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
|
---|
[4] | 1582 | if @in_interval
|
---|
| 1583 | @in_interval = false
|
---|
| 1584 | else
|
---|
[20] | 1585 | # @in_interval = false
|
---|
| 1586 | @in_interval = true
|
---|
[4] | 1587 | end
|
---|
[20] | 1588 | @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
|
---|
[4] | 1589 | yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
|
---|
[19] | 1590 |
|
---|
[4] | 1591 | when /\A\[[a-zA-Z0-9._\-]+::[a-zA-Z0-9._\-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
|
---|
| 1592 | yield :V_QUALIFIED_TERM_CODE_REF, $&
|
---|
| 1593 | when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF
|
---|
| 1594 | yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
|
---|
[19] | 1595 | when /\A\[([a-zA-Z0-9()._\-]+::[a-zA-Z0-9._\_-]+)\]/
|
---|
| 1596 | yield :V_TERM_CODE_CONSTRAINT, :V_TERM_CODE_CONSTRAINT
|
---|
[4] | 1597 | when /\A\[[a-zA-Z0-9\(\)\._\-]+::[ \t\n]*/
|
---|
| 1598 | @adl_type.push(:term_constraint)
|
---|
| 1599 | yield :START_TERM_CODE_CONSTRAINT, $&
|
---|
| 1600 | when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF
|
---|
| 1601 | yield :V_LOCAL_TERM_CODE_REF, $&
|
---|
| 1602 | when /\A\[/ # [
|
---|
| 1603 | yield :Left_bracket_code, :Left_bracket_code
|
---|
| 1604 | when /\A\]/ # ]
|
---|
| 1605 | yield :Right_bracket_code, :Right_bracket_code
|
---|
| 1606 | when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER
|
---|
| 1607 | yield :V_GENERIC_TYPE_IDENTIFIER, $&
|
---|
| 1608 | when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X][T\t][hH?X][hH?X]:[mM?X][mM?X]:[sS?X][sS?X]/
|
---|
| 1609 | yield :V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN, $&
|
---|
| 1610 | when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X]/
|
---|
| 1611 | yield :V_ISO8601_DATE_CONSTRAINT_PATTERN, $&
|
---|
| 1612 | when /\A[hH][hH]:[mM?X][mM?X]:[sS?X][sS?X]/
|
---|
| 1613 | yield :V_ISO8601_TIME_CONSTRAINT_PATTERN, $&
|
---|
| 1614 | when /\A[a-z][a-zA-Z0-9_]*/
|
---|
| 1615 | word = $&.dup
|
---|
| 1616 | if @@cadl_reserved[word.downcase]
|
---|
| 1617 | yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]
|
---|
| 1618 | else
|
---|
[19] | 1619 | @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}:#{@lineno}")
|
---|
[4] | 1620 | yield :V_ATTRIBUTE_IDENTIFIER, word #V_ATTRIBUTE_IDENTIFIER /\A[a-z][a-zA-Z0-9_]*/
|
---|
| 1621 | end
|
---|
| 1622 | when /\A[A-Z][a-zA-Z0-9_]*/
|
---|
| 1623 | word = $&.dup
|
---|
| 1624 | if @@cadl_reserved[word.downcase]
|
---|
| 1625 | yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]
|
---|
| 1626 | else
|
---|
| 1627 | yield :V_TYPE_IDENTIFIER, $&
|
---|
| 1628 | end
|
---|
| 1629 | when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE
|
---|
| 1630 | yield :V_LOCAL_CODE, $&
|
---|
| 1631 | when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
|
---|
| 1632 | yield :V_ISO8601_EXTENDED_DATE_TIME, $&
|
---|
| 1633 | when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
|
---|
| 1634 | yield :V_ISO8601_EXTENDED_TIME, $&
|
---|
| 1635 | when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
|
---|
| 1636 | yield :V_ISO8601_EXTENDED_DATE, $&
|
---|
| 1637 | when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER
|
---|
| 1638 | yield :V_INTEGER, $&
|
---|
| 1639 | when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL
|
---|
| 1640 | yield :V_REAL, $&
|
---|
[19] | 1641 | when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
|
---|
[4] | 1642 | when /\A"([^"]*)"/m #V_STRING
|
---|
| 1643 | yield :V_STRING, $1
|
---|
| 1644 | when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
|
---|
| 1645 | yield :V_URI, $&
|
---|
[19] | 1646 | ### when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
|
---|
| 1647 | ### yield :V_ISO8601_DURATION, $&
|
---|
[4] | 1648 | when /\A\S/ #UTF8CHAR
|
---|
| 1649 | yield :UTF8CHAR, $&
|
---|
| 1650 | else
|
---|
| 1651 | raise
|
---|
| 1652 | end
|
---|
| 1653 | data = $' # variable $' receives the string after the match
|
---|
| 1654 | when :adl
|
---|
| 1655 | # puts "Entering scan_adl"
|
---|
| 1656 | data = scan_adl(data) do |sym, val|
|
---|
| 1657 | yield sym, val
|
---|
| 1658 | end
|
---|
| 1659 | when :dadl
|
---|
| 1660 | # puts "Entering scan_dadl"
|
---|
| 1661 | data = scan_dadl(data) do |sym, val|
|
---|
| 1662 | yield sym, val
|
---|
| 1663 | end
|
---|
| 1664 | when :regexp
|
---|
| 1665 | # puts "Entering scan_regexp"
|
---|
| 1666 | data = scan_regexp(data) do |sym, val|
|
---|
| 1667 | yield sym, val
|
---|
| 1668 | end
|
---|
| 1669 | when :term_constraint
|
---|
| 1670 | # puts "Entering scan_term_constraint"
|
---|
| 1671 | data = scan_term_constraint(data) do |sym, val|
|
---|
| 1672 | yield sym, val
|
---|
| 1673 | end
|
---|
| 1674 | else
|
---|
| 1675 | raise
|
---|
| 1676 | end
|
---|
| 1677 | end # of until
|
---|
| 1678 | end # of scan_cadl
|
---|
| 1679 |
|
---|
| 1680 | def scan_dadl(data)
|
---|
| 1681 | until data.nil? do
|
---|
| 1682 | case @adl_type.last
|
---|
| 1683 | when :dadl
|
---|
| 1684 | # puts "Entering scan_dadl"
|
---|
[17] | 1685 | case scanned = @@dadl_scanner.parse(data)
|
---|
| 1686 | when Yaparc::Result::OK
|
---|
| 1687 | yield scanned.value
|
---|
| 1688 | data = scanned.input
|
---|
| 1689 | else
|
---|
| 1690 | end
|
---|
| 1691 |
|
---|
[4] | 1692 | case data
|
---|
| 1693 | when /\A\n/ # carriage return
|
---|
| 1694 | @lineno += 1
|
---|
| 1695 | ;
|
---|
| 1696 | when /\A[ \t\r\f]+/ #just drop it
|
---|
| 1697 | ;
|
---|
| 1698 | when /\A--.*\n/ # single line comment
|
---|
| 1699 | @lineno += 1
|
---|
[19] | 1700 | @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")
|
---|
[4] | 1701 | ;
|
---|
| 1702 | ###----------/* symbols */ -------------------------------------------------
|
---|
| 1703 | when /\A\=/ # =
|
---|
| 1704 | yield :SYM_EQ, :SYM_EQ
|
---|
| 1705 | when /\A\>\=/ # >=
|
---|
| 1706 | yield :SYM_GE, :SYM_GE
|
---|
| 1707 | when /\A\<\=/ # <=
|
---|
| 1708 | yield :SYM_LE, :SYM_LE
|
---|
| 1709 | when /\A\</ # <
|
---|
| 1710 | if @in_interval
|
---|
| 1711 | yield :SYM_LT, :SYM_LT
|
---|
| 1712 | else
|
---|
| 1713 | @adl_type.push(:dadl)
|
---|
| 1714 | yield :SYM_START_DBLOCK, :SYM_START_DBLOCK
|
---|
| 1715 | end
|
---|
| 1716 | when /\A\>/ # >
|
---|
| 1717 | if @in_interval
|
---|
[20] | 1718 | # @in_interval = false
|
---|
[4] | 1719 | yield :SYM_GT, :SYM_GT
|
---|
[16] | 1720 | elsif @in_c_domain_type == true
|
---|
| 1721 | assert_at(__FILE__,__LINE__){@adl_type.last == :dadl}
|
---|
[14] | 1722 | adl_type = @adl_type.pop
|
---|
[16] | 1723 | if @adl_type.last == :cadl
|
---|
| 1724 | @in_c_domain_type = false
|
---|
| 1725 | yield :END_V_C_DOMAIN_TYPE_BLOCK, $&
|
---|
| 1726 | else
|
---|
| 1727 | yield :SYM_END_DBLOCK, $&
|
---|
| 1728 | end
|
---|
| 1729 | elsif @in_c_domain_type == false
|
---|
[4] | 1730 | adl_type = @adl_type.pop
|
---|
| 1731 | # puts "Escaping #{adl_type}"
|
---|
| 1732 | assert_at(__FILE__,__LINE__){adl_type == :dadl}
|
---|
[16] | 1733 | yield :SYM_END_DBLOCK, $&
|
---|
| 1734 | else
|
---|
| 1735 | raise
|
---|
[4] | 1736 | end
|
---|
| 1737 | when /\A\-/ # -
|
---|
| 1738 | yield :Minus_code, :Minus_code
|
---|
| 1739 | when /\A\+/ # +
|
---|
| 1740 | yield :Plus_code, :Plus_code
|
---|
| 1741 | when /\A\*/ # *
|
---|
| 1742 | yield :Star_code, :Star_code
|
---|
| 1743 | when /\A\// # /
|
---|
| 1744 | yield :Slash_code, :Slash_code
|
---|
| 1745 | when /\A\^/ # ^
|
---|
| 1746 | yield :Caret_code, :Caret_code
|
---|
| 1747 | when /\A\.\.\./ # ...
|
---|
| 1748 | yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
|
---|
| 1749 | when /\A\.\./ # ..
|
---|
| 1750 | yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
|
---|
| 1751 | when /\A\./ # .
|
---|
| 1752 | yield :Dot_code, :Dot_code
|
---|
| 1753 | when /\A\;/ # ;
|
---|
| 1754 | yield :Semicolon_code, :Semicolon_code
|
---|
| 1755 | when /\A\,/ # ,
|
---|
| 1756 | yield :Comma_code, :Comma_code
|
---|
| 1757 | when /\A\:/ # :
|
---|
| 1758 | yield :Colon_code, :Colon_code
|
---|
| 1759 | when /\A\!/ # !
|
---|
| 1760 | yield :Exclamation_code, :Exclamation_code
|
---|
| 1761 | when /\A\(/ # (
|
---|
| 1762 | yield :Left_parenthesis_code, :Left_parenthesis_code
|
---|
| 1763 | when /\A\)/ # )
|
---|
| 1764 | yield :Right_parenthesis_code, :Right_parenthesis_code
|
---|
| 1765 | when /\A\$/ # $
|
---|
| 1766 | yield :Dollar_code, :Dollar_code
|
---|
| 1767 | when /\A\?\?/ # ??
|
---|
| 1768 | yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
|
---|
| 1769 | when /\A\?/ # ?
|
---|
| 1770 | yield :Question_mark_code, :Question_mark_code
|
---|
| 1771 | when /\A\|/ # |
|
---|
[20] | 1772 | @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")
|
---|
[4] | 1773 | if @in_interval
|
---|
| 1774 | @in_interval = false
|
---|
| 1775 | else
|
---|
[20] | 1776 | # @in_interval = false
|
---|
| 1777 | @in_interval = true
|
---|
[4] | 1778 | end
|
---|
[20] | 1779 | @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")
|
---|
[4] | 1780 | yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
|
---|
[17] | 1781 | ### when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
|
---|
| 1782 | ### yield :V_QUALIFIED_TERM_CODE_REF, $&
|
---|
| 1783 | ### when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF
|
---|
| 1784 | ### yield :V_LOCAL_TERM_CODE_REF, $&
|
---|
[18] | 1785 | ### when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF
|
---|
| 1786 | ### yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
|
---|
[4] | 1787 | when /\A\[/ # [
|
---|
| 1788 | yield :Left_bracket_code, :Left_bracket_code
|
---|
| 1789 | when /\A\]/ # ]
|
---|
| 1790 | yield :Right_bracket_code, :Right_bracket_code
|
---|
[18] | 1791 | ### when /\A[A-Z][a-zA-Z0-9_-]*/
|
---|
| 1792 | ### yield :V_TYPE_IDENTIFIER, $&
|
---|
| 1793 | ### when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER
|
---|
| 1794 | ### yield :V_GENERIC_TYPE_IDENTIFIER, $&
|
---|
| 1795 | ### when /\A[a-z][a-zA-Z0-9_]*/
|
---|
| 1796 | ### word = $&.downcase
|
---|
| 1797 | ### if @@dadl_reserved[word]
|
---|
| 1798 | ### yield @@dadl_reserved[word], @@dadl_reserved[word]
|
---|
| 1799 | ### else
|
---|
| 1800 | ### yield :V_ATTRIBUTE_IDENTIFIER, $&
|
---|
| 1801 | ### end
|
---|
| 1802 | ### when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE
|
---|
| 1803 | ### yield :V_LOCAL_CODE, $&
|
---|
[4] | 1804 | when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
|
---|
| 1805 | yield :V_ISO8601_EXTENDED_DATE_TIME, $&
|
---|
| 1806 | when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
|
---|
| 1807 | yield :V_ISO8601_EXTENDED_TIME, $&
|
---|
| 1808 | when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
|
---|
| 1809 | yield :V_ISO8601_EXTENDED_DATE, $&
|
---|
| 1810 | when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER
|
---|
| 1811 | yield :V_GENERIC_TYPE_IDENTIFIER, $&
|
---|
| 1812 | when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER
|
---|
| 1813 | yield :V_INTEGER, $&
|
---|
[18] | 1814 | ### when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL
|
---|
| 1815 | ### yield :V_REAL, $&
|
---|
[4] | 1816 | # when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
|
---|
[18] | 1817 | ### when /\A"([^"]*)"/m #V_STRING
|
---|
| 1818 | ### yield :V_STRING, $1
|
---|
[4] | 1819 | when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
|
---|
| 1820 | yield :V_URI, $&
|
---|
[19] | 1821 | ### when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
|
---|
| 1822 | ### yield :V_ISO8601_DURATION, $&
|
---|
[4] | 1823 | when /\A\S/ #UTF8CHAR
|
---|
| 1824 | yield :UTF8CHAR, $&
|
---|
| 1825 | end
|
---|
| 1826 | data = $' # variable $' receives the string after the match
|
---|
| 1827 | when :adl
|
---|
| 1828 | # puts "Entering scan_adl"
|
---|
| 1829 | data = scan_adl(data) do |sym, val|
|
---|
| 1830 | yield sym, val
|
---|
| 1831 | end
|
---|
| 1832 | when :cadl
|
---|
| 1833 | # puts "Entering scan_cadl"
|
---|
| 1834 | data = scan_cadl(data) do |sym, val|
|
---|
| 1835 | yield sym, val
|
---|
| 1836 | end
|
---|
| 1837 | when :regexp
|
---|
| 1838 | # puts "Entering scan_regexp"
|
---|
| 1839 | data = scan_regexp(data) do |sym, val|
|
---|
| 1840 | yield sym, val
|
---|
| 1841 | end
|
---|
| 1842 | when :term_constraint
|
---|
| 1843 | # puts "Entering scan_term_constraint"
|
---|
| 1844 | data = scan_term_constraint(data) do |sym, val|
|
---|
| 1845 | yield sym, val
|
---|
| 1846 | end
|
---|
| 1847 | else
|
---|
| 1848 | raise
|
---|
| 1849 | end
|
---|
| 1850 | end
|
---|
| 1851 | end # of scan_dadl
|
---|
| 1852 |
|
---|
| 1853 | def scan_regexp(data)
|
---|
| 1854 | until data.nil? do
|
---|
| 1855 | case @adl_type.last
|
---|
| 1856 | when :regexp
|
---|
| 1857 | # puts "Entering scan_regexp"
|
---|
| 1858 | case data
|
---|
| 1859 | when /\A\/\}/ #V_REGEXP
|
---|
| 1860 | if @adl_type.last == :regexp
|
---|
| 1861 | @in_regexp = false
|
---|
| 1862 | @adl_type.pop
|
---|
| 1863 | yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK
|
---|
| 1864 | else
|
---|
| 1865 | raise
|
---|
| 1866 | end
|
---|
| 1867 | when /\A(.*)(\/\})/ #V_REGEXP
|
---|
| 1868 | yield :REGEXP_BODY, $1
|
---|
| 1869 | if @adl_type.last == :regexp
|
---|
| 1870 | @in_regexp = false
|
---|
| 1871 | @adl_type.pop
|
---|
| 1872 | yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK
|
---|
| 1873 | else
|
---|
| 1874 | raise
|
---|
| 1875 | end
|
---|
| 1876 | else
|
---|
| 1877 | raise data
|
---|
| 1878 | end
|
---|
| 1879 | data = $' # variable $' receives the string after the match
|
---|
| 1880 | when :adl
|
---|
| 1881 | # puts "Entering scan_adl"
|
---|
| 1882 | data = scan_adl(data) do |sym, val|
|
---|
| 1883 | yield sym, val
|
---|
| 1884 | end
|
---|
| 1885 | when :dadl
|
---|
| 1886 | # puts "Entering scan_dadl"
|
---|
| 1887 | data = scan_dadl(data) do |sym, val|
|
---|
| 1888 | yield sym, val
|
---|
| 1889 | end
|
---|
| 1890 | when :cadl
|
---|
| 1891 | # puts "Entering scan_cadl"
|
---|
| 1892 | data = scan_cadl(data) do |sym, val|
|
---|
| 1893 | yield sym, val
|
---|
| 1894 | end
|
---|
| 1895 | when :term_constraint
|
---|
| 1896 | # puts "Entering scan_term_constraint"
|
---|
| 1897 | data = scan_term_constraint(data) do |sym, val|
|
---|
| 1898 | yield sym, val
|
---|
| 1899 | end
|
---|
| 1900 | else
|
---|
| 1901 | raise
|
---|
| 1902 | end
|
---|
| 1903 | end
|
---|
| 1904 | end # of scan_regexp
|
---|
| 1905 |
|
---|
| 1906 | def scan_term_constraint(data)
|
---|
| 1907 | until data.nil? do
|
---|
| 1908 | case @adl_type.last
|
---|
| 1909 | when :term_constraint
|
---|
| 1910 | # puts "Entering scan_term_constraint"
|
---|
| 1911 | case data
|
---|
| 1912 | when /\A\n/ # carriage return
|
---|
| 1913 | @lineno += 1
|
---|
| 1914 | ;
|
---|
| 1915 | when /\A[ \t\r\f]+/ #just drop it
|
---|
| 1916 | ;
|
---|
| 1917 | when /\A--.*$/ # single line comment
|
---|
| 1918 | @lineno += 1
|
---|
[19] | 1919 | @@log.info("#{__FILE__}:#{__LINE__}: scan_term_constraint: COMMENT = #{$&} at #{@filename}:#{@lineno}")
|
---|
[4] | 1920 | ;
|
---|
| 1921 | when /\A[a-zA-Z0-9\._\-]+[ \t]*,/ # match any line, with ',' termination
|
---|
| 1922 | yield :TERM_CODE, $&
|
---|
| 1923 | when /\A[a-zA-Z0-9\._\-]+[ \t]*;/ #match second last line with ';' termination (assumed value)
|
---|
| 1924 | yield :TERM_CODE, $&
|
---|
| 1925 | # when /\A[a-zA-Z0-9\._\-]+[ \t]*\]/ # match final line, terminating in ']'
|
---|
| 1926 | when /\A[a-zA-Z0-9\._\-]*[ \t]*\]/ # match final line, terminating in ']'
|
---|
| 1927 | adl_type = @adl_type.pop
|
---|
| 1928 | assert_at(__FILE__,__LINE__){adl_type == :term_constraint}
|
---|
| 1929 | yield :END_TERM_CODE_CONSTRAINT, $&
|
---|
| 1930 | else
|
---|
| 1931 | raise "data = #{data}"
|
---|
| 1932 | end
|
---|
| 1933 | data = $' # variable $' receives the string after the match
|
---|
| 1934 | when :adl
|
---|
| 1935 | # puts "Entering scan_adl"
|
---|
| 1936 | data = scan_adl(data) do |sym, val|
|
---|
| 1937 | yield sym, val
|
---|
| 1938 | end
|
---|
| 1939 | when :dadl
|
---|
| 1940 | # puts "Entering scan_dadl"
|
---|
| 1941 | data = scan_dadl(data) do |sym, val|
|
---|
| 1942 | yield sym, val
|
---|
| 1943 | end
|
---|
| 1944 | when :cadl
|
---|
| 1945 | # puts "Entering scan_cadl"
|
---|
| 1946 | data = scan_cadl(data) do |sym, val|
|
---|
| 1947 | yield sym, val
|
---|
| 1948 | end
|
---|
| 1949 | else
|
---|
| 1950 | raise
|
---|
| 1951 | end
|
---|
| 1952 | end
|
---|
| 1953 | end # of scan_term_constraint
|
---|
| 1954 |
|
---|
| 1955 |
|
---|
| 1956 | def parse(data, filename, lineno = 1, debug = false)
|
---|
| 1957 | @yydebug = true
|
---|
| 1958 | @parsestring = data
|
---|
| 1959 | @data = data
|
---|
| 1960 | @lineno = lineno
|
---|
| 1961 | @filename = filename
|
---|
| 1962 | @adl_type = [:adl] # {:adl, :cadl, :dadl}
|
---|
| 1963 | @in_regexp = false
|
---|
| 1964 | @in_interval = false
|
---|
[14] | 1965 | @in_c_domain_type = false
|
---|
[4] | 1966 | yyparse self, :scan
|
---|
| 1967 | end
|
---|
| 1968 |
|
---|
| 1969 | def on_error( t, v, values)
|
---|
| 1970 | raise Racc::ParseError, "#{@filename}:#{@lineno}: Inline syntax error on #{v.inspect}"
|
---|
| 1971 | end
|
---|
| 1972 |
|
---|
| 1973 |
|
---|
| 1974 |
|
---|
| 1975 |
|
---|
| 1976 |
|
---|
| 1977 |
|
---|
| 1978 |
|
---|
| 1979 | ### Local Variables:
|
---|
| 1980 | ### mode:ruby
|
---|
| 1981 | ### mode:font-lock
|
---|
| 1982 | ### comment-column:0
|
---|
| 1983 | ### comment-start: "### "
|
---|
| 1984 | ### comment-end:""
|
---|
| 1985 | ### End:
|
---|
| 1986 |
|
---|
| 1987 |
|
---|
| 1988 |
|
---|
| 1989 |
|
---|