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