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

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

commit at the timing of leaving Pittsburgh

File size: 41.4 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 }
[4]804
805integer_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
809integer_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
819real_value: V_REAL
[23]820 {
821 begin
822 real = Float(val[0])
823 rescue
824 raise
825 end
826 result = real
827 }
[18]828 | Plus_code V_REAL
[23]829 {
830 begin
[25]831 real = Float(val[1])
[23]832 rescue
833 raise
834 end
835 result = real
836 }
[18]837 | Minus_code V_REAL
[23]838 {
839 begin
[25]840 real = Float(val[1])
[23]841 rescue
842 raise
843 end
844 result = - real
845 }
[4]846
847real_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
851real_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
862boolean_value: SYM_TRUE
[23]863 {
864 result = true
865 }
[4]866 | SYM_FALSE
[23]867 {
868 result = false
869 }
[4]870
871boolean_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
875character_value: V_CHARACTER
876
877character_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
881date_value: V_ISO8601_EXTENDED_DATE
[283]882 {
883 result = val[0]
884 }
[4]885
886date_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
890date_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
900time_value: V_ISO8601_EXTENDED_TIME
901
902time_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
906time_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
916date_time_value: V_ISO8601_EXTENDED_DATE_TIME
[320]917 {
918 @@logger.debug("V_ISO8601_EXTENDED_DATE_TIME: #{val[0]} at #{@filename}:#{@lineno}")
919 result = val[0]
920 }
[4]921
922date_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
926date_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
936duration_value: V_ISO8601_DURATION
[19]937 {
[261]938 @@logger.debug("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
[22]939 result = val[0]
[19]940 }
[4]941
942duration_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
946duration_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
956term_code: V_QUALIFIED_TERM_CODE_REF
[20]957 {
[261]958 @@logger.debug("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
[26]959 result = val[0]
[20]960 }
[4]961
962term_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
966uri_value: V_URI
[20]967 {
[261]968 @@logger.debug("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
[26]969 result = val[0]
[20]970 }
[4]971
972
973#---------------------- ASSERTIONS ------------------------
974
975assertions: assertion
976 | assertions assertion
977
[321]978assertion: any_identifier Colon_code boolean_expression
[4]979 | boolean_expression
[321]980 | any_identifier Colon_code error
[4]981
982#---------------------- expressions ---------------------
983
984boolean_expression: boolean_leaf
985 | boolean_node
986
987boolean_node: SYM_EXISTS absolute_path
[321]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 }
[4]994 | relative_path SYM_MATCHES SYM_START_CBLOCK c_primitive SYM_END_CBLOCK
[321]995# | relative_path SYM_MATCHES SYM_START_CBLOCK Slash_code REGEXP_BODY Slash_code SYM_END_CBLOCK# added by akimichi
[4]996 | SYM_NOT boolean_leaf
[321]997 | arithmetic_expression Equal_code arithmetic_expression
[4]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
1008boolean_leaf: Left_parenthesis_code boolean_expression Right_parenthesis_code
1009 | SYM_TRUE
1010 | SYM_FALSE
1011
[323]1012arithmetic_node: arithmetic_expression Plus_code arithmetic_leaf
[321]1013 | arithmetic_expression Minus_code arithmetic_leaf
[4]1014 | arithmetic_expression Star_code arithmetic_leaf
1015 | arithmetic_expression Slash_code arithmetic_leaf
[321]1016 | arithmetic_expression Caret_code arithmetic_leaf
[4]1017
1018arithmetic_leaf: Left_parenthesis_code arithmetic_expression Right_parenthesis_code
1019 | integer_value
1020 | real_value
1021 | absolute_path
1022
[321]1023arithmetic_expression: arithmetic_leaf
1024 | arithmetic_node
[4]1025
1026#--------------- THE FOLLOWING SOURCE TAKEN FROM OG_PATH_VALIDATOR.Y -------------
1027#--------------- except to remove movable_path ----------------------------------------------------
1028
1029
1030absolute_path: Slash_code
1031 | Slash_code relative_path
1032# | absolute_path Slash_code relative_path
1033
1034
1035
1036relative_path: path_segment
[321]1037 {
1038 @@logger.debug("#{__FILE__}:#{__LINE__}, relative_path = #{val[0]}")
1039 result = val[0]
1040 }
[4]1041 | relative_path Slash_code path_segment
[321]1042 {
1043 @@logger.debug("#{__FILE__}:#{__LINE__}, relative_path = #{val[0]}/#{val[2]}")
1044 result = [val[0],val[2]]
1045 }
[4]1046
1047path_segment: V_ATTRIBUTE_IDENTIFIER V_LOCAL_TERM_CODE_REF
[19]1048 {
[261]1049 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")
[321]1050 result = [val[0],val[1]]
[19]1051 }
[4]1052 | V_ATTRIBUTE_IDENTIFIER
[19]1053 {
[261]1054 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")
[321]1055 result = val[0]
[19]1056 }
[4]1057
1058
1059#-------------------------------- END SOURCE TAKEN FROM OG_PATH_VALIDATOR.Y ----------------------
1060
1061
1062#---------------- existence, occurrences, cardinality ----------------
1063
1064c_existence: #-- default to 1..1
[22]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 }
[4]1072
1073existence_spec: V_INTEGER #-- can only be 0 or 1
[22]1074 {
1075 begin
1076 integer = Integer(val[0])
1077 rescue
1078 raise
1079 end
1080 result = integer
1081 }
[4]1082 | V_INTEGER SYM_ELLIPSIS V_INTEGER #-- can only be 0..0, 0..1, 1..1
[22]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 }
[4]1092
1093c_cardinality: SYM_CARDINALITY SYM_MATCHES SYM_START_CBLOCK cardinality_spec SYM_END_CBLOCK
[22]1094 {
[318]1095 result = OpenEhr::AM::Archetype::ConstraintModel::CARDINALITY.new
[22]1096 }
[4]1097
1098cardinality_spec: occurrence_spec
[323]1099 {
1100 result = val[0]
1101 }
[4]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
1110cardinality_limit_value: integer_value
[35]1111 {
1112 result = val[0]
1113 }
1114 | Star_code # '*'
1115 {
1116 result = val[0]
1117 }
[4]1118
[35]1119
[4]1120c_occurrences: #-- default to 1..1
1121 | SYM_OCCURRENCES SYM_MATCHES SYM_START_CBLOCK occurrence_spec SYM_END_CBLOCK
[23]1122 {
[307]1123 case val[3]
1124 when OpenEhr::RM::Support::AssumedTypes::Interval
1125 result = val[3]
1126 else
1127 result = val[3]
1128 end
[23]1129 }
[4]1130 | SYM_OCCURRENCES error
1131
1132occurrence_spec: cardinality_limit_value #-- single integer or '*'
[307]1133 {
1134 result = val[0]
1135 }
[4]1136 | V_INTEGER SYM_ELLIPSIS cardinality_limit_value
[307]1137 {
1138 result = OpenEhr::RM::Support::AssumedTypes::Interval.new(val[0], val[2])
1139 }
[4]1140
1141#---------------------- leaf constraint types -----------------------
1142
1143c_integer_spec: integer_value
1144 | integer_list_value
1145 | integer_interval_value
1146
1147c_integer: c_integer_spec
1148 | c_integer_spec Semicolon_code integer_value
1149 | c_integer_spec Semicolon_code error
1150
1151c_real_spec: real_value
1152 | real_list_value
1153 | real_interval_value
1154
1155c_real: c_real_spec
1156 | c_real_spec Semicolon_code real_value
1157 | c_real_spec Semicolon_code error
1158
1159c_date_constraint: V_ISO8601_DATE_CONSTRAINT_PATTERN
1160 | date_value
1161 | date_interval_value
1162
1163c_date: c_date_constraint
1164 | c_date_constraint Semicolon_code date_value
1165 | c_date_constraint Semicolon_code error
1166
1167c_time_constraint: V_ISO8601_TIME_CONSTRAINT_PATTERN
1168 | time_value
1169 | time_interval_value
1170
1171c_time: c_time_constraint
1172 | c_time_constraint Semicolon_code time_value
1173 | c_time_constraint Semicolon_code error
1174
1175c_date_time_constraint: V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN
1176 | date_time_value
1177 | date_time_interval_value
1178
1179c_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
1183c_duration_constraint: duration_pattern
1184 | duration_pattern Slash_code duration_interval_value
1185 | duration_value
1186 | duration_interval_value
1187
1188c_duration: c_duration_constraint
1189 | c_duration_constraint Semicolon_code duration_value
1190 | c_duration_constraint Semicolon_code error
1191
1192c_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
1198c_string: c_string_spec
1199 | c_string_spec Semicolon_code string_value
1200 | c_string_spec Semicolon_code error
1201
1202c_boolean_spec: SYM_TRUE
[22]1203 {
[318]1204 result = OpenEhr::AM::Archetype::ConstraintModel::Primitive::C_BOOLEAN.new(:true_valid => true)
[22]1205 }
[4]1206 | SYM_FALSE
[22]1207 {
[318]1208 result = OpenEhr::AM::Archetype::ConstraintModel::Primitive::C_BOOLEAN.new(:true_valid => false)
[22]1209 }
[4]1210 | SYM_TRUE Comma_code SYM_FALSE
[22]1211 {
[318]1212 result = OpenEhr::AM::Archetype::ConstraintModel::Primitive::C_BOOLEAN.new(:true_valid => true,:false_valid => false)
[22]1213 }
[4]1214 | SYM_FALSE Comma_code SYM_TRUE
[22]1215 {
[318]1216 result = OpenEhr::AM::Archetype::ConstraintModel::Primitive::C_BOOLEAN.new(:true_valid => false,:false_valid => true)
[22]1217 }
[4]1218
1219c_boolean: c_boolean_spec
[22]1220 {
1221 result = val[0]
1222 }
[4]1223 | c_boolean_spec Semicolon_code boolean_value
[22]1224 {
[321]1225 result = val[0]
1226 #raise 'Not implemented yet'
[22]1227 }
[19]1228 | c_boolean_spec Semicolon_code error
[22]1229 {
1230 raise 'Not implemented yet'
1231 }
[4]1232
1233c_ordinal: c_ordinal_spec
1234 | c_ordinal_spec Semicolon_code integer_value
[19]1235 | c_ordinal_spec Semicolon_code error
[4]1236
1237c_ordinal_spec: ordinal
1238 | c_ordinal_spec Comma_code ordinal
1239
1240ordinal: integer_value SYM_INTERVAL_DELIM V_QUALIFIED_TERM_CODE_REF
[20]1241 {
1242 @in_interval = false
[261]1243 @@logger.debug("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}")
[20]1244 }
[4]1245
1246#c_code_phrase: V_TERM_CODE_CONSTRAINT #-- e.g. "[local::at0040, at0041; at0040]"
1247c_code_phrase: term_code_constraint_section #-- e.g. "[local::at0040, at0041; at0040]"
[32]1248 {
1249 result = val[0]
1250 }
[4]1251 | V_QUALIFIED_TERM_CODE_REF
[32]1252 {
1253 result = val[0]
1254 }
[4]1255
[261]1256# [[a-zA-Z0-9\(\)\._\-]+::[ \t\n]* [[a-zA-Z0-9\._\-]*[ \t]*]
[4]1257term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT
[261]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
[4]1266term_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.
1273constraint_ref: V_LOCAL_TERM_CODE_REF #-- e.g. "ac0003"
[32]1274 {
1275 result = val[0]
1276 }
[4]1277
1278any_identifier: type_identifier
[32]1279 {
1280 result = val[0]
1281 }
[4]1282 | V_ATTRIBUTE_IDENTIFIER
[19]1283 {
[261]1284 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
[32]1285 result = val[0]
[19]1286 }
[4]1287
1288
1289#----------------- TAKEN FROM DADL_VALIDATOR.Y -------------------
1290#----------------- DO NOT MODIFY -------------------
1291#---------------------- BASIC DATA VALUES -----------------------
1292
1293duration_pattern: V_ISO8601_DURATION_CONSTRAINT_PATTERN
[318]1294 {
1295 result = OpenEhr::AM::Archetype::ConstraintModel::Primitive::C_DURATION.new #val[0]
[26]1296 }
[4]1297
1298
1299
1300---- header
1301
[49]1302
[4]1303$:.unshift File.join(File.dirname(__FILE__))
[17]1304require 'logger'
[283]1305require 'yaml'
[21]1306require 'rubygems'
[307]1307require '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
[4]1314
1315
[17]1316
[4]1317---- inner
[17]1318
[22]1319def assert_at(file,line, message = "")
1320 unless yield
1321 raise "Assertion failed !: #{file}, #{line}: #{message}"
1322 end
1323end
1324
[49]1325if $DEBUG
[261]1326 @@logger = Logger.new('log/parser.log','daily')
[263]1327 @@logger.level = Logger::DEBUG
[49]1328else
[261]1329 @@logger = Logger.new(STDOUT)
1330 @@logger.level = Logger::WARN
[49]1331end
1332
[17]1333
[4]1334
1335###----------/* Scanner */ -----------------------------------------------
1336
[265]1337
[4]1338def scan
[261]1339 @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan at #{@filename}:#{@lineno}:")
[307]1340 scanner = OpenEhr::ADL::Scanner::ADLScanner.new(@adl_type, @filename)
[265]1341
[4]1342 until @data.nil? do
[283]1343 @data = scanner.scan(@data) do |sym, val|
[4]1344 yield sym, val
1345 end
1346 @data = $' # variable $' receives the string after the match
1347 end
1348 yield :EOF, nil
1349 yield false, '$'
1350end # of scan
1351
[265]1352
[4]1353def 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
[14]1362 @in_c_domain_type = false
[4]1363 yyparse self, :scan
1364end
1365
1366def on_error( t, v, values)
1367 raise Racc::ParseError, "#{@filename}:#{@lineno}: Inline syntax error on #{v.inspect}"
1368end
1369
1370
[283]1371__END__
[4]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
Note: See TracBrowser for help on using the repository browser.