source: ruby/trunk/lib/adl_parser/lib/parser.y@ 321

Last change on this file since 321 was 321, checked in by Tatsukawa, Akimichi, 15 years ago

commit from Pittsburgh

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