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