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