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