require 'shared_token_grammar' require 'dadl_grammar' require 'cadl_grammar' require 'adl' module OpenEHR module Parser grammar ADLGrammar include SharedToken include DADLGrammar include CADL rule archetype arch_identification arch_specialisation? arch_concept arch_language? arch_description? arch_definition arch_invariant? arch_ontology { def archetype_id arch_identification.archetype_id end def adl_version arch_identification.adl_version end def concept arch_concept.value end def original_language elements[3].original_language end def translations elements[3].translations end def description elements[4].values end def definition arch_definition.value end } end rule arch_identification head:arch_head V_ARCHETYPE_ID space { def archetype_id elements[1].text_value end def adl_version head.adl_version end } end rule arch_head SYM_ARCHETYPE m:arch_meta_data? { def adl_version m.adl_version end } end rule arch_meta_data '(' arch_meta_data_items ')' space { def adl_version arch_meta_data_items.adl_version end } end rule arch_meta_data_items item:arch_meta_data_item (';' other_item:arch_meta_data_item)* { def adl_version item.adl_version end def is_controled? item.is_controled? or other_item.map {|i| i.is_controled} end } end rule arch_meta_data_item SYM_ADL_VERSION SYM_EQ V_VERSION_STRING space { def adl_version elements[2].text_value end } / SYM_IS_CONTROLED space { def is_controled? true if elements[0] end } end rule arch_specialisation SYM_SPECIALIZE arch_id:V_ARCHETYPE_ID space { def specialised? true if elements[0] end def archetype_id arch_id.text_value end } end rule arch_concept SYM_CONCEPT conc:V_LOCAL_TERM_CODE_REF space { def value conc.text_value[1..-2] end } end rule arch_language SYM_LANGUAGE lang:V_DADL_TEXT end rule arch_description SYM_DESCRIPTION desc:V_DADL_TEXT space { def values desc.value end } end rule arch_definition SYM_DEFINITION definition:V_CADL_TEXT space { def value definition.value end } end rule arch_invariant SYM_INVARIANT V_ASSERTION_TEXT space end rule arch_ontology SYM_ONTOLOGY V_DADL_TEXT space end end end end