Changeset 316


Ignore:
Timestamp:
Oct 12, 2009, 4:20:00 PM (15 years ago)
Author:
Tatsukawa, Akimichi
Message:

refactoring ADL scanners to handle the syntax more properly

Location:
ruby/trunk/lib/adl_parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/adl_parser/lib/adl_scanner.rb

    r315 r316  
    7777                @@logger.debug("ADLScanner#scan: COMMENT = #{$&} at #{@filename}:#{@lineno}")
    7878                ;
    79               when /\Adescription/   # description
     79              when /\Alanguage/   # language section
     80                assert_at(__FILE__,__LINE__){@adl_type.pop == :adl}
     81                @adl_type.push(:dadl)
     82                yield :SYM_LANGUAGE, :SYM_LANGUAGE
     83              when /\Adescription/   # description section
     84                assert_at(__FILE__,__LINE__){@adl_type.pop == :dadl}
     85                @adl_type.push(:dadl)
    8086                yield :SYM_DESCRIPTION, :SYM_DESCRIPTION
    81               when /\Adefinition/   # definition
     87              when /\Adefinition/   # definition section
     88                assert_at(__FILE__,__LINE__){@adl_type.pop == :dadl}
     89                @adl_type.push(:cadl)
    8290                yield :SYM_DEFINITION, :SYM_DEFINITION
     91              when /\Aontology/   # ontology section
     92                assert_at(__FILE__,__LINE__){@adl_type.pop == :cadl}
     93                @adl_type.push(:dadl)
     94                yield :SYM_ONTOLOGY, :SYM_ONTOLOGY
     95              when /\Ainvariatn/   # invariant section
     96                raise
    8397              ###----------/* symbols */ -------------------------------------------------
    8498              when /\A[A-Z][a-zA-Z0-9_]*/
     
    316330                      yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
    317331                    end
    318 #                     adl_type = @adl_type.pop
    319 #                     if adl_type == :dadl
    320 #                       yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
    321 #                     else
    322 #                       @in_c_domain_type = false
    323 #                       yield :END_V_C_DOMAIN_TYPE_BLOCK, :END_V_C_DOMAIN_TYPE_BLOCK
    324 #                     end
    325332                  else
    326333                    adl_type = @adl_type.pop
  • ruby/trunk/lib/adl_parser/test/parser_test.rb

    r315 r316  
    66  end
    77
    8 #   must "assert parser instance" do
    9 #     assert_instance_of ::OpenEhr::ADL::Parser,@parser
    10 #   end
    11 
    12 #   must "openEHR-EHR-SECTION.summary.v1.adl be properly parsed" do
    13 #     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.summary.v1.adl")
    14 #     assert_nothing_raised do
    15 #       ast = @parser.parse(file, 'openEHR-EHR-SECTION.summary.v1')
    16 #       assert_instance_of OpenEhr::RM::Support::Identification::ArchetypeID, ast.archetype_id
    17 #     end
    18 #   end
     8  must "assert parser instance" do
     9    assert_instance_of ::OpenEhr::ADL::Parser,@parser
     10  end
     11
     12  must "openEHR-EHR-SECTION.summary.v1.adl be properly parsed" do
     13    file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.summary.v1.adl")
     14    assert_nothing_raised do
     15      ast = @parser.parse(file, 'openEHR-EHR-SECTION.summary.v1')
     16      assert_instance_of OpenEhr::RM::Support::Identification::ArchetypeID, ast.archetype_id
     17    end
     18  end
    1919
    2020#   must "openEHR-EHR-ACTION.imaging.v1.adl be properly parsed" do
     
    223223#   end
    224224
    225   must "openEHR-EHR-OBSERVATION.body_mass_index.v1.adl be properly parsed" do
    226     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl")
    227     assert_nothing_raised do
    228       ast = @parser.parse(file, 'openEHR-EHR-OBSERVATION.body_mass_index.v1')
    229       assert_instance_of OpenEhr::RM::Support::Identification::ArchetypeID, ast.archetype_id
    230     end
    231   end
     225#   must "openEHR-EHR-OBSERVATION.body_mass_index.v1.adl be properly parsed" do
     226#     file =  File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl")
     227#     assert_nothing_raised do
     228#       ast = @parser.parse(file, 'openEHR-EHR-OBSERVATION.body_mass_index.v1')
     229#       assert_instance_of OpenEhr::RM::Support::Identification::ArchetypeID, ast.archetype_id
     230#     end
     231#   end
    232232
    233233
Note: See TracChangeset for help on using the changeset viewer.