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