Changeset 290 for ruby/branches/0.5/lib
- Timestamp:
- Sep 24, 2009, 9:51:27 AM (15 years ago)
- Location:
- ruby/branches/0.5
- Files:
-
- 1 deleted
- 13 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5
-
Property svn:mergeinfo
set to
/ruby/trunk merged eligible
-
Property svn:mergeinfo
set to
-
ruby/branches/0.5/lib/adl_parser/Rakefile
r164 r290 1 1 require 'rubygems' 2 #Gem::manage_gems3 2 require 'rake' 4 3 require 'rake/testtask' … … 26 25 end 27 26 end 28 29 30 27 31 28 desc "Generate TAGS by rtags." … … 79 76 s.name = 'adl_parser' 80 77 s.author = 'Akimichi Tatsukawa' 81 s.version = '0.0. 3'78 s.version = '0.0.4' 82 79 s.summary = 'ADL parser' 83 80 s.email = 'akimichi.tatsukawa@gmail.com' … … 85 82 candidates = Dir.glob("{bin,docs,lib,test,ext}/**/*") 86 83 s.files = candidates.delete_if do |item| 87 item.include?(".svn") || item.include?("rdoc") 84 item.include?(".svn") || item.include?("rdoc") || item.include?("log") 88 85 end 89 86 s.files = FileList['README', 'COPYING', 'Rakefile'] … … 91 88 s.has_rdoc = true 92 89 s.extra_rdoc_files = ["README"] 93 s.add_dependency("yaparc", ">= 0.2.3")94 s.add_dependency("openehr_models", ">= 0.0. 1")90 # s.add_dependency("yaparc", ">= 0.2.3") 91 s.add_dependency("openehr_models", ">= 0.0.3") 95 92 end 96 93 … … 105 102 106 103 107 108 109 104 ### Local Variables: 110 105 ### mode:ruby -
ruby/branches/0.5/lib/adl_parser/lib/adl_parser.rb
r167 r290 8 8 $:.unshift File.join(File.dirname(__FILE__)) 9 9 require 'logger' 10 require 'adl_scanner.rb' 11 require 'adl_exception.rb' 10 12 11 13 module OpenEhr … … 18 20 LOG.level = Logger::WARN 19 21 end 20 21 22 22 23 23 … … 25 25 autoload :Parser, "parser.rb" 26 26 autoload :Validator, "validator.rb" 27 27 28 28 module Scanner 29 29 module DADL 30 autoload :RootScanner, "scanner.rb" 30 autoload :RootScanner, "adl_scanner.rb" 31 end 32 module CADL 33 autoload :RootScanner, "adl_scanner.rb" 31 34 end 32 35 end -
ruby/branches/0.5/lib/adl_parser/lib/adl_scanner.rb
- Property svn:mergeinfo changed
/ruby/trunk/lib/adl_parser/lib/adl_scanner.rb (added) merged: 2-260
- Property svn:mergeinfo changed
-
ruby/branches/0.5/lib/adl_parser/lib/parser.rb
r167 r290 11 11 $:.unshift File.join(File.dirname(__FILE__)) 12 12 require 'logger' 13 #require 'lib/util.rb' 14 #require 'lib/scanner.rb' 15 require 'lib/adl_parser.rb' 13 require 'yaml' 16 14 require 'rubygems' 15 require 'adl_parser.rb' 17 16 require 'am.rb' 17 require 'rm.rb' 18 18 $DEBUG = false 19 19 … … 24 24 class Parser < Racc::Parser 25 25 26 module_eval(<<'...end parser.y/module_eval...', 'parser.y', 1 183)26 module_eval(<<'...end parser.y/module_eval...', 'parser.y', 1208) 27 27 28 28 def assert_at(file,line, message = "") … … 33 33 34 34 if $DEBUG 35 @@log = Logger.new('log/parser.log','daily')36 @@log .level = Logger::INFO35 @@logger = Logger.new('log/parser.log','daily') 36 @@logger.level = Logger::DEBUG 37 37 else 38 @@log = Logger.new(STDOUT)39 @@log .level = Logger::WARN38 @@logger = Logger.new(STDOUT) 39 @@logger.level = Logger::WARN 40 40 end 41 41 42 @@dadl_scanner = OpenEHR::ADL::Scanner::DADL::RootScanner.new43 @@cadl_scanner = OpenEHR::ADL::Scanner::CADL::RootScanner.new44 42 45 43 ###----------/* keywords */ --------------------------------------------- … … 101 99 ###----------/* Scanner */ ----------------------------------------------- 102 100 101 103 102 def scan 103 @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan at #{@filename}:#{@lineno}:") 104 scanner = OpenEHR::ADL::Scanner::ADLScanner.new(@adl_type, @filename) 105 104 106 until @data.nil? do 105 case @adl_type.last 106 when :adl 107 @data = scan_adl(@data) do |sym, val| 107 @data = scanner.scan(@data) do |sym, val| 108 108 yield sym, val 109 end110 when :dadl111 @data = scan_dadl(@data) do |sym, val|112 yield sym, val113 end114 when :cadl115 @data = scan_cadl(@data) do |sym, val|116 yield sym, val117 end118 when :regexp119 @data = scan_regexp(@data) do |sym, val|120 yield sym, val121 end122 else123 raise124 109 end 125 110 @data = $' # variable $' receives the string after the match … … 128 113 yield false, '$' 129 114 end # of scan 130 131 def scan_adl(data)132 until data.nil? do133 case @adl_type.last134 when :adl135 # puts "Entering scan_adl"136 case data137 when /\A\n/ # carriage return138 @lineno += 1139 ;140 when /\A[ \t\r\f]+/ #just drop it141 ;142 when /\A--.*\n/ # single line comment143 @lineno += 1144 @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")145 ;146 when /\Adescription/ # description147 yield :SYM_DESCRIPTION, :SYM_DESCRIPTION148 when /\Adefinition/ # definition149 yield :SYM_DEFINITION, :SYM_DEFINITION150 # @adl_type.push(:cadl)151 ###----------/* symbols */ -------------------------------------------------152 when /\A[A-Z][a-zA-Z0-9_]*/153 yield :V_TYPE_IDENTIFIER, $&154 when /\A[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z0-9]+/ #V_ARCHETYPE_ID155 yield :V_ARCHETYPE_ID, $&156 when /\A[a-z][a-zA-Z0-9_]*/157 # word = $&.downcase158 word = $&159 if @@adl_reserved[word]160 @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: @@adl_reserved = #{@@adl_reserved[word]} at #{@filename}:#{@lineno}")161 yield @@adl_reserved[word], @@adl_reserved[word]162 elsif #/\A[A-Z][a-zA-Z0-9_]*/163 @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: V_ATTRIBUTE_IDENTIFIER = #{$&} at #{@filename}:#{@lineno}")164 yield :V_ATTRIBUTE_IDENTIFIER, $&165 end166 when /\A\=/ # =167 yield :SYM_EQ, :SYM_EQ168 when /\A\>=/ # >=169 yield :SYM_GE, :SYM_GE170 when /\A\<=/ # <=171 yield :SYM_LE, :SYM_LE172 when /\A\</ # <173 if @in_interval174 # @start_block_received = false175 yield :SYM_LT, :SYM_LT176 else177 # @start_block_received = true178 @adl_type.push(:dadl)179 yield :SYM_START_DBLOCK, $&180 end181 when /\A\>/ # >182 if @in_interval183 yield :SYM_GT, :SYM_GT184 else185 adl_type = @adl_type.pop186 # puts "Escaping #{adl_type}"187 assert_at(__FILE__,__LINE__){adl_type == :dadl}188 yield :SYM_END_DBLOCK, :SYM_END_DBLOCK189 end190 when /\A\{/ # {191 @adl_type.push(:cadl)192 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")193 yield :SYM_START_CBLOCK, :SYM_START_CBLOCK194 when /\A\}/ # }195 adl_type = @adl_type.pop196 # puts "Escaping #{adl_type}"197 assert_at(__FILE__,__LINE__){adl_type == :cadl}198 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")199 yield :SYM_END_CBLOCK, $&200 when /\A\-/ # -201 yield :Minus_code, :Minus_code202 when /\A\+/ # +203 yield :Plus_code, :Plus_code204 when /\A\*/ # *205 yield :Star_code, :Star_code206 when /\A\// # /207 yield :Slash_code, :Slash_code208 when /\A\^/ # ^209 yield :Caret_code, :Caret_code210 when /\A\=/ # =211 yield :Equal_code, :Equal_code212 when /\A\.\.\./ # ...213 yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE214 when /\A\.\./ # ..215 yield :SYM_ELLIPSIS, :SYM_ELLIPSIS216 when /\A\./ # .217 yield :Dot_code, :Dot_code218 when /\A\;/ # ;219 yield :Semicolon_code, :Semicolon_code220 when /\A\,/ # ,221 yield :Comma_code, :Comma_code222 when /\A\:/ # :223 yield :Colon_code, :Colon_code224 when /\A\!/ # !225 yield :Exclamation_code, :Exclamation_code226 when /\A\(/ # (227 yield :Left_parenthesis_code, :Left_parenthesis_code228 when /\A\)/ # )229 yield :Right_parenthesis_code, :Right_parenthesis_code230 when /\A\$/ # $231 yield :Dollar_code, :Dollar_code232 when /\A\?\?/ # ??233 yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN234 when /\A\?/ # ?235 yield :Question_mark_code, :Question_mark_code236 when /\A[0-9]+\.[0-9]+(\.[0-9]+)*/ # ?237 yield :V_VERSION_STRING, :V_VERSION_STRING238 when /\A\|/ # |239 if @in_interval240 @in_interval = false241 else242 @in_interval = true243 end244 yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM245 when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/246 # when /\A\[[a-zA-Z0-9()\._-]+\:\:[a-zA-Z0-9\._-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]247 yield :V_QUALIFIED_TERM_CODE_REF, $&248 when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF249 yield :V_LOCAL_TERM_CODE_REF, $&250 when /\A\[/ # [251 yield :Left_bracket_code, :Left_bracket_code252 when /\A\]/ # ]253 yield :Right_bracket_code, :Right_bracket_code254 255 when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF256 yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&257 when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE258 yield :V_LOCAL_CODE, $&259 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-260 yield :V_ISO8601_EXTENDED_DATE_TIME, $&261 when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]262 yield :V_ISO8601_EXTENDED_TIME, $&263 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD264 yield :V_ISO8601_EXTENDED_DATE, $&265 when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER266 yield :V_GENERIC_TYPE_IDENTIFIER, $&267 when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER268 yield :V_INTEGER, $&269 when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL270 yield :V_REAL, $&271 # when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING272 when /\A"([^"]*)"/m #V_STRING273 yield :V_STRING, $1274 when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI275 yield :V_URI, $&276 when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS277 yield :V_ISO8601_DURATION, $&278 when /\A\S/ #UTF8CHAR279 yield :UTF8CHAR, $&280 end281 data = $' # variable $' receives the string after the match282 when :dadl283 # puts "Entering scan_dadl"284 data = scan_dadl(data) do |sym, val|285 yield sym, val286 end287 when :cadl288 # puts "Entering scan_cadl"289 data = scan_cadl(data) do |sym, val|290 yield sym, val291 end292 when :regexp293 # puts "Entering scan_regexp"294 data = scan_regexp(data) do |sym, val|295 yield sym, val296 end297 when :term_constraint298 # puts "Entering scan_term_constraint"299 data = scan_term_constraint(data) do |sym, val|300 yield sym, val301 end302 else303 raise304 end305 end306 end # scan_adl307 308 309 def scan_cadl(data)310 until data.nil? do311 case @adl_type.last312 when :cadl313 # puts "Entering scan_cadl"314 case scanned = @@cadl_scanner.parse(data)315 when Yaparc::Result::OK316 if scanned.value[0] == :START_V_C_DOMAIN_TYPE_BLOCK317 @in_c_domain_type = true318 @adl_type.push(:dadl)319 yield scanned.value320 else321 yield scanned.value322 end323 data = scanned.input324 end325 326 case data327 when /\A\n/ # carriage return328 @lineno += 1329 ;330 when /\A[ \t\r\f]+/ #just drop it331 ;332 when /\A--.*\n/ # single line comment333 @lineno += 1334 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")335 ;336 ###----------/* symbols */ -------------------------------------------------337 when /\A\=/ # =338 yield :SYM_EQ, :SYM_EQ339 when /\A\>=/ # >=340 yield :SYM_GE, :SYM_GE341 when /\A\<=/ # <=342 yield :SYM_LE, :SYM_LE343 ### when /\A[A-Z][a-zA-Z0-9_]*[ \n]*\</ # V_C_DOMAIN_TYPE344 ### @in_c_domain_type = true345 ### @adl_type.push(:dadl)346 ### yield :START_V_C_DOMAIN_TYPE_BLOCK, $&347 when /\A\</ # <348 if @in_interval349 yield :SYM_LT, :SYM_LT350 else351 @adl_type.push(:dadl)352 yield :SYM_START_DBLOCK, $&353 end354 when /\A\>/ # >355 if @in_interval356 yield :SYM_GT, :SYM_GT357 else358 adl_type = @adl_type.pop359 # puts "Escaping #{adl_type}"360 assert_at(__FILE__,__LINE__){adl_type == :dadl}361 yield :SYM_END_DBLOCK, :SYM_END_DBLOCK362 end363 when /\A\-/ # -364 yield :Minus_code, :Minus_code365 when /\A\+/ # +366 yield :Plus_code, :Plus_code367 when /\A\*/ # *368 yield :Star_code, :Star_code369 when /\A\// # /370 yield :Slash_code, :Slash_code371 when /\A\^/ # ^372 yield :Caret_code, :Caret_code373 when /\A\.\.\./ # ...374 yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE375 when /\A\.\./ # ..376 yield :SYM_ELLIPSIS, :SYM_ELLIPSIS377 when /\A\./ # .378 yield :Dot_code, :Dot_code379 when /\A\;/ # ;380 yield :Semicolon_code, :Semicolon_code381 when /\A\,/ # ,382 yield :Comma_code, :Comma_code383 when /\A\:/ # :384 yield :Colon_code, :Colon_code385 when /\A\!/ # !386 yield :Exclamation_code, :Exclamation_code387 when /\A\(/ # (388 yield :Left_parenthesis_code, :Left_parenthesis_code389 when /\A\)/ # )390 yield :Right_parenthesis_code, :Right_parenthesis_code391 when /\A\{\// #V_REGEXP392 if @adl_type.last != :regexp393 @in_regexp = true394 @adl_type.push(:regexp)395 yield :START_REGEXP_BLOCK, :START_REGEXP_BLOCK396 else397 raise398 end399 # yield :V_REGEXP, :V_REGEXP400 when /\A\{/ # {401 @adl_type.push(:cadl)402 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")403 yield :SYM_START_CBLOCK, :SYM_START_CBLOCK404 when /\A\}/ # }405 adl_type = @adl_type.pop406 # puts "Escaping #{adl_type}"407 assert_at(__FILE__,__LINE__){adl_type == :cadl}408 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")409 yield :SYM_END_CBLOCK, :SYM_END_CBLOCK410 when /\A\$/ # $411 yield :Dollar_code, :Dollar_code412 when /\A\?\?/ # ??413 yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN414 when /\A\?/ # ?415 yield :Question_mark_code, :Question_mark_code416 when /\A\|/ # |417 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")418 if @in_interval419 @in_interval = false420 else421 # @in_interval = false422 @in_interval = true423 end424 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")425 yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM426 427 when /\A\[[a-zA-Z0-9._\-]+::[a-zA-Z0-9._\-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]428 yield :V_QUALIFIED_TERM_CODE_REF, $&429 when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF430 yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&431 when /\A\[([a-zA-Z0-9()._\-]+::[a-zA-Z0-9._\_-]+)\]/432 yield :V_TERM_CODE_CONSTRAINT, :V_TERM_CODE_CONSTRAINT433 when /\A\[[a-zA-Z0-9\(\)\._\-]+::[ \t\n]*/434 @adl_type.push(:term_constraint)435 yield :START_TERM_CODE_CONSTRAINT, $&436 when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF437 yield :V_LOCAL_TERM_CODE_REF, $&438 when /\A\[/ # [439 yield :Left_bracket_code, :Left_bracket_code440 when /\A\]/ # ]441 yield :Right_bracket_code, :Right_bracket_code442 when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER443 yield :V_GENERIC_TYPE_IDENTIFIER, $&444 when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X][T\t][hH?X][hH?X]:[mM?X][mM?X]:[sS?X][sS?X]/445 yield :V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN, $&446 when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X]/447 yield :V_ISO8601_DATE_CONSTRAINT_PATTERN, $&448 when /\A[hH][hH]:[mM?X][mM?X]:[sS?X][sS?X]/449 yield :V_ISO8601_TIME_CONSTRAINT_PATTERN, $&450 when /\A[a-z][a-zA-Z0-9_]*/451 word = $&.dup452 if @@cadl_reserved[word.downcase]453 yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]454 else455 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}:#{@lineno}")456 yield :V_ATTRIBUTE_IDENTIFIER, word #V_ATTRIBUTE_IDENTIFIER /\A[a-z][a-zA-Z0-9_]*/457 end458 when /\A[A-Z][a-zA-Z0-9_]*/459 word = $&.dup460 if @@cadl_reserved[word.downcase]461 yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]462 else463 yield :V_TYPE_IDENTIFIER, $&464 end465 when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE466 yield :V_LOCAL_CODE, $&467 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-468 yield :V_ISO8601_EXTENDED_DATE_TIME, $&469 when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]470 yield :V_ISO8601_EXTENDED_TIME, $&471 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD472 yield :V_ISO8601_EXTENDED_DATE, $&473 when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER474 yield :V_INTEGER, $&475 when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL476 yield :V_REAL, $&477 when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING478 when /\A"([^"]*)"/m #V_STRING479 yield :V_STRING, $1480 when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI481 yield :V_URI, $&482 ### when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS483 ### yield :V_ISO8601_DURATION, $&484 when /\A\S/ #UTF8CHAR485 yield :UTF8CHAR, $&486 else487 raise488 end489 data = $' # variable $' receives the string after the match490 when :adl491 # puts "Entering scan_adl"492 data = scan_adl(data) do |sym, val|493 yield sym, val494 end495 when :dadl496 # puts "Entering scan_dadl"497 data = scan_dadl(data) do |sym, val|498 yield sym, val499 end500 when :regexp501 # puts "Entering scan_regexp"502 data = scan_regexp(data) do |sym, val|503 yield sym, val504 end505 when :term_constraint506 # puts "Entering scan_term_constraint"507 data = scan_term_constraint(data) do |sym, val|508 yield sym, val509 end510 else511 raise512 end513 end # of until514 end # of scan_cadl515 516 def scan_dadl(data)517 until data.nil? do518 case @adl_type.last519 when :dadl520 # puts "Entering scan_dadl"521 case scanned = @@dadl_scanner.parse(data)522 when Yaparc::Result::OK523 yield scanned.value524 data = scanned.input525 else526 end527 528 case data529 when /\A\n/ # carriage return530 @lineno += 1531 ;532 when /\A[ \t\r\f]+/ #just drop it533 ;534 when /\A--.*\n/ # single line comment535 @lineno += 1536 @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")537 ;538 ###----------/* symbols */ -------------------------------------------------539 when /\A\=/ # =540 yield :SYM_EQ, :SYM_EQ541 when /\A\>\=/ # >=542 yield :SYM_GE, :SYM_GE543 when /\A\<\=/ # <=544 yield :SYM_LE, :SYM_LE545 when /\A\</ # <546 if @in_interval547 yield :SYM_LT, :SYM_LT548 else549 @adl_type.push(:dadl)550 yield :SYM_START_DBLOCK, :SYM_START_DBLOCK551 end552 when /\A\>/ # >553 if @in_interval554 # @in_interval = false555 yield :SYM_GT, :SYM_GT556 elsif @in_c_domain_type == true557 assert_at(__FILE__,__LINE__){@adl_type.last == :dadl}558 adl_type = @adl_type.pop559 if @adl_type.last == :cadl560 @in_c_domain_type = false561 yield :END_V_C_DOMAIN_TYPE_BLOCK, $&562 else563 yield :SYM_END_DBLOCK, $&564 end565 elsif @in_c_domain_type == false566 adl_type = @adl_type.pop567 # puts "Escaping #{adl_type}"568 assert_at(__FILE__,__LINE__){adl_type == :dadl}569 yield :SYM_END_DBLOCK, $&570 else571 raise572 end573 when /\A\-/ # -574 yield :Minus_code, :Minus_code575 when /\A\+/ # +576 yield :Plus_code, :Plus_code577 when /\A\*/ # *578 yield :Star_code, :Star_code579 when /\A\// # /580 yield :Slash_code, :Slash_code581 when /\A\^/ # ^582 yield :Caret_code, :Caret_code583 when /\A\.\.\./ # ...584 yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE585 when /\A\.\./ # ..586 yield :SYM_ELLIPSIS, :SYM_ELLIPSIS587 when /\A\./ # .588 yield :Dot_code, :Dot_code589 when /\A\;/ # ;590 yield :Semicolon_code, :Semicolon_code591 when /\A\,/ # ,592 yield :Comma_code, :Comma_code593 when /\A\:/ # :594 yield :Colon_code, :Colon_code595 when /\A\!/ # !596 yield :Exclamation_code, :Exclamation_code597 when /\A\(/ # (598 yield :Left_parenthesis_code, :Left_parenthesis_code599 when /\A\)/ # )600 yield :Right_parenthesis_code, :Right_parenthesis_code601 when /\A\$/ # $602 yield :Dollar_code, :Dollar_code603 when /\A\?\?/ # ??604 yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN605 when /\A\?/ # ?606 yield :Question_mark_code, :Question_mark_code607 when /\A\|/ # |608 @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")609 if @in_interval610 @in_interval = false611 else612 # @in_interval = false613 @in_interval = true614 end615 @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")616 yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM617 ### when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]618 ### yield :V_QUALIFIED_TERM_CODE_REF, $&619 ### when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF620 ### yield :V_LOCAL_TERM_CODE_REF, $&621 ### when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF622 ### yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&623 when /\A\[/ # [624 yield :Left_bracket_code, :Left_bracket_code625 when /\A\]/ # ]626 yield :Right_bracket_code, :Right_bracket_code627 ### when /\A[A-Z][a-zA-Z0-9_-]*/628 ### yield :V_TYPE_IDENTIFIER, $&629 ### when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER630 ### yield :V_GENERIC_TYPE_IDENTIFIER, $&631 ### when /\A[a-z][a-zA-Z0-9_]*/632 ### word = $&.downcase633 ### if @@dadl_reserved[word]634 ### yield @@dadl_reserved[word], @@dadl_reserved[word]635 ### else636 ### yield :V_ATTRIBUTE_IDENTIFIER, $&637 ### end638 ### when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE639 ### yield :V_LOCAL_CODE, $&640 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-641 yield :V_ISO8601_EXTENDED_DATE_TIME, $&642 when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]643 yield :V_ISO8601_EXTENDED_TIME, $&644 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD645 yield :V_ISO8601_EXTENDED_DATE, $&646 when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER647 yield :V_GENERIC_TYPE_IDENTIFIER, $&648 when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER649 yield :V_INTEGER, $&650 ### when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL651 ### yield :V_REAL, $&652 # when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING653 ### when /\A"([^"]*)"/m #V_STRING654 ### yield :V_STRING, $1655 when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI656 yield :V_URI, $&657 ### when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS658 ### yield :V_ISO8601_DURATION, $&659 when /\A\S/ #UTF8CHAR660 yield :UTF8CHAR, $&661 end662 data = $' # variable $' receives the string after the match663 when :adl664 # puts "Entering scan_adl"665 data = scan_adl(data) do |sym, val|666 yield sym, val667 end668 when :cadl669 # puts "Entering scan_cadl"670 data = scan_cadl(data) do |sym, val|671 yield sym, val672 end673 when :regexp674 # puts "Entering scan_regexp"675 data = scan_regexp(data) do |sym, val|676 yield sym, val677 end678 when :term_constraint679 # puts "Entering scan_term_constraint"680 data = scan_term_constraint(data) do |sym, val|681 yield sym, val682 end683 else684 raise685 end686 end687 end # of scan_dadl688 689 def scan_regexp(data)690 until data.nil? do691 case @adl_type.last692 when :regexp693 # puts "Entering scan_regexp"694 case data695 when /\A\/\}/ #V_REGEXP696 if @adl_type.last == :regexp697 @in_regexp = false698 @adl_type.pop699 yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK700 else701 raise702 end703 when /\A(.*)(\/\})/ #V_REGEXP704 yield :REGEXP_BODY, $1705 if @adl_type.last == :regexp706 @in_regexp = false707 @adl_type.pop708 yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK709 else710 raise711 end712 else713 raise data714 end715 data = $' # variable $' receives the string after the match716 when :adl717 # puts "Entering scan_adl"718 data = scan_adl(data) do |sym, val|719 yield sym, val720 end721 when :dadl722 # puts "Entering scan_dadl"723 data = scan_dadl(data) do |sym, val|724 yield sym, val725 end726 when :cadl727 # puts "Entering scan_cadl"728 data = scan_cadl(data) do |sym, val|729 yield sym, val730 end731 when :term_constraint732 # puts "Entering scan_term_constraint"733 data = scan_term_constraint(data) do |sym, val|734 yield sym, val735 end736 else737 raise738 end739 end740 end # of scan_regexp741 742 def scan_term_constraint(data)743 until data.nil? do744 case @adl_type.last745 when :term_constraint746 # puts "Entering scan_term_constraint"747 case data748 when /\A\n/ # carriage return749 @lineno += 1750 ;751 when /\A[ \t\r\f]+/ #just drop it752 ;753 when /\A--.*$/ # single line comment754 @lineno += 1755 @@log.info("#{__FILE__}:#{__LINE__}: scan_term_constraint: COMMENT = #{$&} at #{@filename}:#{@lineno}")756 ;757 when /\A[a-zA-Z0-9\._\-]+[ \t]*,/ # match any line, with ',' termination758 yield :TERM_CODE, $&759 when /\A[a-zA-Z0-9\._\-]+[ \t]*;/ #match second last line with ';' termination (assumed value)760 yield :TERM_CODE, $&761 # when /\A[a-zA-Z0-9\._\-]+[ \t]*\]/ # match final line, terminating in ']'762 when /\A[a-zA-Z0-9\._\-]*[ \t]*\]/ # match final line, terminating in ']'763 adl_type = @adl_type.pop764 assert_at(__FILE__,__LINE__){adl_type == :term_constraint}765 yield :END_TERM_CODE_CONSTRAINT, $&766 else767 raise "data = #{data}"768 end769 data = $' # variable $' receives the string after the match770 when :adl771 # puts "Entering scan_adl"772 data = scan_adl(data) do |sym, val|773 yield sym, val774 end775 when :dadl776 # puts "Entering scan_dadl"777 data = scan_dadl(data) do |sym, val|778 yield sym, val779 end780 when :cadl781 # puts "Entering scan_cadl"782 data = scan_cadl(data) do |sym, val|783 yield sym, val784 end785 else786 raise787 end788 end789 end # of scan_term_constraint790 115 791 116 … … 808 133 809 134 810 135 __END__ 811 136 812 137 … … 1128 453 -376, -376, -376, -195, -376, -208, -376, -221, -376, -234, 1129 454 -376, -376, -376, -43, -305, -376, -53, -44, -376, -376, 1130 -31, -72, -310, -70, -3 5, -37, -372, -38, -39, -360,1131 -40, -376, -363, -41, -367, -366, -42, -369, -376, -3 6,455 -31, -72, -310, -70, -36, -37, -372, -38, -39, -360, 456 -40, -376, -363, -41, -367, -366, -42, -369, -376, -35, 1132 457 -376, -376, -376, -376, -376, -309, -160, -175, -159, -376, 1133 458 -174, -376, -196, -376, -209, -376, -222, -376, -235, -376, … … 1306 631 1, 109, :_reduce_12, 1307 632 0, 99, :_reduce_none, 1308 2, 99, :_reduce_ none,633 2, 99, :_reduce_14, 1309 634 2, 99, :_reduce_none, 1310 635 2, 100, :_reduce_16, … … 1337 662 1, 121, :_reduce_none, 1338 663 1, 121, :_reduce_none, 1339 3, 12 2, :_reduce_45,1340 4, 12 3, :_reduce_46,1341 3, 12 3, :_reduce_none,1342 6, 12 4, :_reduce_48,664 3, 128, :_reduce_45, 665 4, 122, :_reduce_46, 666 3, 122, :_reduce_none, 667 6, 123, :_reduce_48, 1343 668 2, 130, :_reduce_49, 1344 669 2, 133, :_reduce_50, 1345 670 3, 133, :_reduce_none, 1346 671 2, 133, :_reduce_none, 1347 1, 12 8, :_reduce_53,672 1, 127, :_reduce_53, 1348 673 1, 134, :_reduce_54, 1349 674 1, 134, :_reduce_55, … … 1483 808 3, 189, :_reduce_none, 1484 809 3, 189, :_reduce_none, 1485 1, 180, :_reduce_ none,810 1, 180, :_reduce_191, 1486 811 3, 190, :_reduce_none, 1487 812 3, 190, :_reduce_none, … … 1652 977 3, 142, :_reduce_358, 1653 978 3, 142, :_reduce_359, 1654 1, 12 7, :_reduce_none,1655 3, 12 7, :_reduce_none,1656 3, 12 7, :_reduce_none,979 1, 126, :_reduce_none, 980 3, 126, :_reduce_none, 981 3, 126, :_reduce_none, 1657 982 1, 221, :_reduce_none, 1658 983 3, 221, :_reduce_none, 1659 984 3, 222, :_reduce_365, 1660 1, 12 6, :_reduce_366,1661 1, 12 6, :_reduce_367,1662 3, 223, :_reduce_ none,985 1, 125, :_reduce_366, 986 1, 125, :_reduce_367, 987 3, 223, :_reduce_368, 1663 988 0, 224, :_reduce_none, 1664 989 1, 224, :_reduce_none, 1665 990 2, 224, :_reduce_none, 1666 1, 12 5, :_reduce_372,991 1, 124, :_reduce_372, 1667 992 1, 150, :_reduce_373, 1668 993 1, 150, :_reduce_374, … … 1913 1238 "c_attributes", 1914 1239 "c_object", 1915 "v_c_domain_type",1916 1240 "archetype_internal_ref", 1917 1241 "archetype_slot", … … 1920 1244 "c_ordinal", 1921 1245 "c_primitive_object", 1246 "v_c_domain_type", 1922 1247 "absolute_path", 1923 1248 "c_archetype_slot_head", … … 2040 1365 2041 1366 archetype_id = val[0][:archetype_id] 1367 parent_archtype_id = val[1][:parent_archtype_id] if val[1] 2042 1368 adl_version = val[0][:arch_head][:arch_meta_data][:adl_version] 2043 1369 concept = val[2] … … 2045 1371 archetype = OpenEHR::AM::Archetype::ARCHETYPE.create( 2046 1372 :archetype_id => archetype_id, 1373 :parent_archtype_id => parent_archtype_id, 2047 1374 :adl_version => adl_version, 2048 1375 :concept => concept, … … 2053 1380 archetype.original_language = language 2054 1381 end 2055 @@log .info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")1382 @@logger.debug("#{__FILE__}:#{__LINE__}: archetype = #{archetype.to_yaml} at #{@filename}:#{@lineno}") 2056 1383 result = archetype 2057 1384 … … 2060 1387 .,., 2061 1388 2062 module_eval(<<'.,.,', 'parser.y', 6 1)1389 module_eval(<<'.,.,', 'parser.y', 63) 2063 1390 def _reduce_4(val, _values, result) 2064 1391 result = {:arch_head => val[0], :archetype_id => val[1] } … … 2068 1395 .,., 2069 1396 2070 module_eval(<<'.,.,', 'parser.y', 6 5)1397 module_eval(<<'.,.,', 'parser.y', 67) 2071 1398 def _reduce_5(val, _values, result) 2072 1399 raise … … 2076 1403 .,., 2077 1404 2078 module_eval(<<'.,.,', 'parser.y', 7 0)1405 module_eval(<<'.,.,', 'parser.y', 72) 2079 1406 def _reduce_6(val, _values, result) 2080 1407 result = {:arch_meta_data => nil } … … 2084 1411 .,., 2085 1412 2086 module_eval(<<'.,.,', 'parser.y', 7 4)1413 module_eval(<<'.,.,', 'parser.y', 76) 2087 1414 def _reduce_7(val, _values, result) 2088 1415 result = val[1] … … 2092 1419 .,., 2093 1420 2094 module_eval(<<'.,.,', 'parser.y', 79)1421 module_eval(<<'.,.,', 'parser.y', 81) 2095 1422 def _reduce_8(val, _values, result) 2096 1423 result = {:arch_meta_data => val[1] } … … 2100 1427 .,., 2101 1428 2102 module_eval(<<'.,.,', 'parser.y', 8 4)1429 module_eval(<<'.,.,', 'parser.y', 86) 2103 1430 def _reduce_9(val, _values, result) 2104 1431 result = val[0] … … 2108 1435 .,., 2109 1436 2110 module_eval(<<'.,.,', 'parser.y', 88)1437 module_eval(<<'.,.,', 'parser.y', 90) 2111 1438 def _reduce_10(val, _values, result) 2112 1439 result = val[0].merge(val[2]) … … 2116 1443 .,., 2117 1444 2118 module_eval(<<'.,.,', 'parser.y', 9 4)1445 module_eval(<<'.,.,', 'parser.y', 96) 2119 1446 def _reduce_11(val, _values, result) 2120 1447 result = {:adl_version => val[2], :is_controlled => false } … … 2124 1451 .,., 2125 1452 2126 module_eval(<<'.,.,', 'parser.y', 98)1453 module_eval(<<'.,.,', 'parser.y', 100) 2127 1454 def _reduce_12(val, _values, result) 2128 1455 result = {:is_controlled => true } … … 2134 1461 # reduce 13 omitted 2135 1462 2136 # reduce 14 omitted 1463 module_eval(<<'.,.,', 'parser.y', 108) 1464 def _reduce_14(val, _values, result) 1465 result = {:parent_archtype_id => val[1]} 1466 1467 result 1468 end 1469 .,., 2137 1470 2138 1471 # reduce 15 omitted 2139 1472 2140 module_eval(<<'.,.,', 'parser.y', 1 09)1473 module_eval(<<'.,.,', 'parser.y', 114) 2141 1474 def _reduce_16(val, _values, result) 2142 1475 result = {:arch_concept => val[1] } … … 2148 1481 # reduce 17 omitted 2149 1482 2150 module_eval(<<'.,.,', 'parser.y', 1 19)1483 module_eval(<<'.,.,', 'parser.y', 124) 2151 1484 def _reduce_18(val, _values, result) 2152 1485 result = {:arch_language => nil} … … 2156 1489 .,., 2157 1490 2158 module_eval(<<'.,.,', 'parser.y', 12 3)1491 module_eval(<<'.,.,', 'parser.y', 128) 2159 1492 def _reduce_19(val, _values, result) 2160 1493 result = {:arch_language => val[1]} … … 2168 1501 # reduce 21 omitted 2169 1502 2170 module_eval(<<'.,.,', 'parser.y', 13 4)1503 module_eval(<<'.,.,', 'parser.y', 139) 2171 1504 def _reduce_22(val, _values, result) 2172 1505 result = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new(:details => val[1]) … … 2178 1511 # reduce 23 omitted 2179 1512 2180 module_eval(<<'.,.,', 'parser.y', 14 2)1513 module_eval(<<'.,.,', 'parser.y', 147) 2181 1514 def _reduce_24(val, _values, result) 2182 1515 result = val[1] … … 2188 1521 # reduce 25 omitted 2189 1522 2190 module_eval(<<'.,.,', 'parser.y', 15 0)1523 module_eval(<<'.,.,', 'parser.y', 155) 2191 1524 def _reduce_26(val, _values, result) 2192 1525 assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT)} 2193 @@log .info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}")1526 @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}") 2194 1527 result = val[0] 2195 1528 … … 2198 1531 .,., 2199 1532 2200 module_eval(<<'.,.,', 'parser.y', 1 56)1533 module_eval(<<'.,.,', 'parser.y', 161) 2201 1534 def _reduce_27(val, _values, result) 2202 1535 result = val[0] … … 2206 1539 .,., 2207 1540 2208 module_eval(<<'.,.,', 'parser.y', 16 3)1541 module_eval(<<'.,.,', 'parser.y', 168) 2209 1542 def _reduce_28(val, _values, result) 2210 1543 result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object| … … 2218 1551 .,., 2219 1552 2220 module_eval(<<'.,.,', 'parser.y', 17 1)1553 module_eval(<<'.,.,', 'parser.y', 176) 2221 1554 def _reduce_29(val, _values, result) 2222 1555 result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object| … … 2230 1563 .,., 2231 1564 2232 module_eval(<<'.,.,', 'parser.y', 18 2)1565 module_eval(<<'.,.,', 'parser.y', 187) 2233 1566 def _reduce_30(val, _values, result) 2234 1567 result = {:c_complex_object_id => val[0], :c_occurrences => val[1]} … … 2238 1571 .,., 2239 1572 2240 module_eval(<<'.,.,', 'parser.y', 1 87)1573 module_eval(<<'.,.,', 'parser.y', 192) 2241 1574 def _reduce_31(val, _values, result) 2242 1575 result = {:type_identifier => val[0]} … … 2246 1579 .,., 2247 1580 2248 module_eval(<<'.,.,', 'parser.y', 19 1)1581 module_eval(<<'.,.,', 'parser.y', 196) 2249 1582 def _reduce_32(val, _values, result) 2250 1583 result = {:type_identifier => val[0], :local_term_code_ref => val[1]} … … 2256 1589 # reduce 33 omitted 2257 1590 2258 module_eval(<<'.,.,', 'parser.y', 197)1591 module_eval(<<'.,.,', 'parser.y', 202) 2259 1592 def _reduce_34(val, _values, result) 2260 1593 result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => val[0]) … … 2264 1597 .,., 2265 1598 2266 module_eval(<<'.,.,', 'parser.y', 2 05)1599 module_eval(<<'.,.,', 'parser.y', 220) 2267 1600 def _reduce_35(val, _values, result) 2268 result = val[0] 2269 2270 result 2271 end 2272 .,., 2273 2274 module_eval(<<'.,.,', 'parser.y', 209) 1601 @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}") 1602 result = val[0] 1603 1604 result 1605 end 1606 .,., 1607 1608 module_eval(<<'.,.,', 'parser.y', 225) 2275 1609 def _reduce_36(val, _values, result) 2276 @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}")2277 result = val[0]2278 2279 result2280 end2281 .,.,2282 2283 module_eval(<<'.,.,', 'parser.y', 214)2284 def _reduce_37(val, _values, result)2285 1610 result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.create do |archetype_internal_ref| 2286 1611 archetype_internal_ref.target_path = val[0][:absolute_path] … … 2293 1618 .,., 2294 1619 2295 module_eval(<<'.,.,', 'parser.y', 222) 1620 module_eval(<<'.,.,', 'parser.y', 233) 1621 def _reduce_37(val, _values, result) 1622 result = val[0] 1623 1624 result 1625 end 1626 .,., 1627 1628 module_eval(<<'.,.,', 'parser.y', 237) 2296 1629 def _reduce_38(val, _values, result) 2297 result = val[0]2298 2299 result2300 end2301 .,.,2302 2303 module_eval(<<'.,.,', 'parser.y', 226)2304 def _reduce_39(val, _values, result)2305 1630 result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.create do |constraint_ref| 2306 1631 constraint_ref.reference = val[0] … … 2311 1636 .,., 2312 1637 2313 module_eval(<<'.,.,', 'parser.y', 232) 1638 module_eval(<<'.,.,', 'parser.y', 243) 1639 def _reduce_39(val, _values, result) 1640 result = val[0] 1641 1642 result 1643 end 1644 .,., 1645 1646 module_eval(<<'.,.,', 'parser.y', 247) 2314 1647 def _reduce_40(val, _values, result) 2315 1648 result = val[0] … … 2319 1652 .,., 2320 1653 2321 module_eval(<<'.,.,', 'parser.y', 2 36)1654 module_eval(<<'.,.,', 'parser.y', 251) 2322 1655 def _reduce_41(val, _values, result) 2323 1656 result = val[0] … … 2327 1660 .,., 2328 1661 2329 module_eval(<<'.,.,', 'parser.y', 2 40)1662 module_eval(<<'.,.,', 'parser.y', 255) 2330 1663 def _reduce_42(val, _values, result) 2331 1664 result = val[0] … … 2339 1672 # reduce 44 omitted 2340 1673 2341 module_eval(<<'.,.,', 'parser.y', 2 55)1674 module_eval(<<'.,.,', 'parser.y', 271) 2342 1675 def _reduce_45(val, _values, result) 2343 1676 result = val[1] … … 2347 1680 .,., 2348 1681 2349 module_eval(<<'.,.,', 'parser.y', 2 61)1682 module_eval(<<'.,.,', 'parser.y', 277) 2350 1683 def _reduce_46(val, _values, result) 2351 1684 result = {:type_identifier => val[1], :c_occurrences => val[2], :absolute_path => val[3] } … … 2357 1690 # reduce 47 omitted 2358 1691 2359 module_eval(<<'.,.,', 'parser.y', 2 68)1692 module_eval(<<'.,.,', 'parser.y', 284) 2360 1693 def _reduce_48(val, _values, result) 2361 1694 result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.create do |archetype_slot| … … 2370 1703 .,., 2371 1704 2372 module_eval(<<'.,.,', 'parser.y', 2 77)1705 module_eval(<<'.,.,', 'parser.y', 293) 2373 1706 def _reduce_49(val, _values, result) 2374 1707 result = {:c_archetype_slot_id => val[0],:c_occurrences => val[1]} … … 2378 1711 .,., 2379 1712 2380 module_eval(<<'.,.,', 'parser.y', 2 82)1713 module_eval(<<'.,.,', 'parser.y', 298) 2381 1714 def _reduce_50(val, _values, result) 2382 1715 result = val[1] … … 2390 1723 # reduce 52 omitted 2391 1724 2392 module_eval(<<'.,.,', 'parser.y', 290)1725 module_eval(<<'.,.,', 'parser.y', 306) 2393 1726 def _reduce_53(val, _values, result) 2394 1727 assert_at(__FILE__,__LINE__){val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE)} … … 2401 1734 .,., 2402 1735 2403 module_eval(<<'.,.,', 'parser.y', 298)1736 module_eval(<<'.,.,', 'parser.y', 314) 2404 1737 def _reduce_54(val, _values, result) 2405 @@log .info("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")1738 @@logger.debug("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}") 2406 1739 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.create do |c_integer| 2407 1740 c_integer.list … … 2414 1747 .,., 2415 1748 2416 module_eval(<<'.,.,', 'parser.y', 3 07)1749 module_eval(<<'.,.,', 'parser.y', 323) 2417 1750 def _reduce_55(val, _values, result) 2418 @@log .info("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}")1751 @@logger.debug("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}") 2419 1752 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new 2420 1753 … … 2423 1756 .,., 2424 1757 2425 module_eval(<<'.,.,', 'parser.y', 3 12)1758 module_eval(<<'.,.,', 'parser.y', 328) 2426 1759 def _reduce_56(val, _values, result) 2427 @@log .info("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}")1760 @@logger.debug("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}") 2428 1761 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new 2429 1762 … … 2432 1765 .,., 2433 1766 2434 module_eval(<<'.,.,', 'parser.y', 3 17)1767 module_eval(<<'.,.,', 'parser.y', 333) 2435 1768 def _reduce_57(val, _values, result) 2436 @@log .info("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}")1769 @@logger.debug("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}") 2437 1770 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new 2438 1771 … … 2441 1774 .,., 2442 1775 2443 module_eval(<<'.,.,', 'parser.y', 3 22)1776 module_eval(<<'.,.,', 'parser.y', 338) 2444 1777 def _reduce_58(val, _values, result) 2445 @@log .info("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}")1778 @@logger.debug("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}") 2446 1779 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new 2447 1780 … … 2450 1783 .,., 2451 1784 2452 module_eval(<<'.,.,', 'parser.y', 3 27)1785 module_eval(<<'.,.,', 'parser.y', 343) 2453 1786 def _reduce_59(val, _values, result) 2454 @@log .info("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}")1787 @@logger.debug("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}") 2455 1788 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new 2456 1789 … … 2459 1792 .,., 2460 1793 2461 module_eval(<<'.,.,', 'parser.y', 3 32)1794 module_eval(<<'.,.,', 'parser.y', 348) 2462 1795 def _reduce_60(val, _values, result) 2463 @@log .info("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}")1796 @@logger.debug("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}") 2464 1797 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new 2465 1798 … … 2468 1801 .,., 2469 1802 2470 module_eval(<<'.,.,', 'parser.y', 3 37)1803 module_eval(<<'.,.,', 'parser.y', 353) 2471 1804 def _reduce_61(val, _values, result) 2472 1805 assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN)} 2473 @@log .info("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}")1806 @@logger.debug("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}") 2474 1807 result = val[0] 2475 1808 … … 2480 1813 # reduce 62 omitted 2481 1814 2482 module_eval(<<'.,.,', 'parser.y', 3 49)1815 module_eval(<<'.,.,', 'parser.y', 365) 2483 1816 def _reduce_63(val, _values, result) 2484 1817 result = [val[0]] … … 2488 1821 .,., 2489 1822 2490 module_eval(<<'.,.,', 'parser.y', 3 53)1823 module_eval(<<'.,.,', 'parser.y', 369) 2491 1824 def _reduce_64(val, _values, result) 2492 1825 result = (val[0] << val[1]) … … 2496 1829 .,., 2497 1830 2498 module_eval(<<'.,.,', 'parser.y', 3 59)1831 module_eval(<<'.,.,', 'parser.y', 375) 2499 1832 def _reduce_65(val, _values, result) 2500 1833 assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)} … … 2507 1840 .,., 2508 1841 2509 module_eval(<<'.,.,', 'parser.y', 3 66)1842 module_eval(<<'.,.,', 'parser.y', 382) 2510 1843 def _reduce_66(val, _values, result) 2511 1844 assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)} … … 2516 1849 .,., 2517 1850 2518 module_eval(<<'.,.,', 'parser.y', 3 71)1851 module_eval(<<'.,.,', 'parser.y', 387) 2519 1852 def _reduce_67(val, _values, result) 2520 1853 assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)} … … 2525 1858 .,., 2526 1859 2527 module_eval(<<'.,.,', 'parser.y', 3 78)1860 module_eval(<<'.,.,', 'parser.y', 394) 2528 1861 def _reduce_68(val, _values, result) 2529 @@log .info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}")1862 @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}") 2530 1863 result = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new( 2531 1864 :rm_attribute_name => val[0], … … 2538 1871 .,., 2539 1872 2540 module_eval(<<'.,.,', 'parser.y', 387)1873 module_eval(<<'.,.,', 'parser.y', 403) 2541 1874 def _reduce_69(val, _values, result) 2542 1875 assert_at(__FILE__,__LINE__){ val[2].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY) } 2543 @@log .info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}")1876 @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}") 2544 1877 result = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new( 2545 1878 :rm_attribute_name => val[0], … … 2552 1885 .,., 2553 1886 2554 module_eval(<<'.,.,', 'parser.y', 398)1887 module_eval(<<'.,.,', 'parser.y', 414) 2555 1888 def _reduce_70(val, _values, result) 2556 1889 result = Array[val[0]] … … 2560 1893 .,., 2561 1894 2562 module_eval(<<'.,.,', 'parser.y', 4 02)1895 module_eval(<<'.,.,', 'parser.y', 418) 2563 1896 def _reduce_71(val, _values, result) 2564 1897 result = (val[0] << val[1]) … … 2568 1901 .,., 2569 1902 2570 module_eval(<<'.,.,', 'parser.y', 4 06)1903 module_eval(<<'.,.,', 'parser.y', 422) 2571 1904 def _reduce_72(val, _values, result) 2572 1905 result = Array[val[0]] … … 2578 1911 # reduce 73 omitted 2579 1912 2580 module_eval(<<'.,.,', 'parser.y', 4 14)1913 module_eval(<<'.,.,', 'parser.y', 430) 2581 1914 def _reduce_74(val, _values, result) 2582 1915 result = val[1] … … 2588 1921 # reduce 75 omitted 2589 1922 2590 module_eval(<<'.,.,', 'parser.y', 4 22)1923 module_eval(<<'.,.,', 'parser.y', 438) 2591 1924 def _reduce_76(val, _values, result) 2592 1925 result = val[1] … … 2612 1945 # reduce 84 omitted 2613 1946 2614 module_eval(<<'.,.,', 'parser.y', 4 42)1947 module_eval(<<'.,.,', 'parser.y', 458) 2615 1948 def _reduce_85(val, _values, result) 2616 1949 dadl_section = val[1] … … 2629 1962 # reduce 89 omitted 2630 1963 2631 module_eval(<<'.,.,', 'parser.y', 4 57)1964 module_eval(<<'.,.,', 'parser.y', 473) 2632 1965 def _reduce_90(val, _values, result) 2633 1966 result = Array[val[0]] … … 2637 1970 .,., 2638 1971 2639 module_eval(<<'.,.,', 'parser.y', 4 61)1972 module_eval(<<'.,.,', 'parser.y', 477) 2640 1973 def _reduce_91(val, _values, result) 2641 1974 result = (val[0] << val[1]) … … 2645 1978 .,., 2646 1979 2647 module_eval(<<'.,.,', 'parser.y', 4 65)1980 module_eval(<<'.,.,', 'parser.y', 481) 2648 1981 def _reduce_92(val, _values, result) 2649 1982 result = (val[0] << val[2]) … … 2653 1986 .,., 2654 1987 2655 module_eval(<<'.,.,', 'parser.y', 4 70)1988 module_eval(<<'.,.,', 'parser.y', 486) 2656 1989 def _reduce_93(val, _values, result) 2657 @@log .info("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")1990 @@logger.debug("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]} at #{@filename}:#{@lineno}") 2658 1991 result = {:attr_id => val[0], :object_block => val[2]} 2659 1992 … … 2662 1995 .,., 2663 1996 2664 module_eval(<<'.,.,', 'parser.y', 4 76)1997 module_eval(<<'.,.,', 'parser.y', 492) 2665 1998 def _reduce_94(val, _values, result) 2666 @@log .info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")1999 @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}") 2667 2000 result = val[0] 2668 2001 … … 2673 2006 # reduce 95 omitted 2674 2007 2675 module_eval(<<'.,.,', 'parser.y', 4 83)2008 module_eval(<<'.,.,', 'parser.y', 499) 2676 2009 def _reduce_96(val, _values, result) 2677 2010 result = val[0] … … 2681 2014 .,., 2682 2015 2683 module_eval(<<'.,.,', 'parser.y', 487)2016 module_eval(<<'.,.,', 'parser.y', 503) 2684 2017 def _reduce_97(val, _values, result) 2685 2018 result = val[0] … … 2689 2022 .,., 2690 2023 2691 module_eval(<<'.,.,', 'parser.y', 492)2024 module_eval(<<'.,.,', 'parser.y', 508) 2692 2025 def _reduce_98(val, _values, result) 2693 2026 result = val[0] … … 2697 2030 .,., 2698 2031 2699 module_eval(<<'.,.,', 'parser.y', 496)2032 module_eval(<<'.,.,', 'parser.y', 512) 2700 2033 def _reduce_99(val, _values, result) 2701 2034 result = val[0] … … 2705 2038 .,., 2706 2039 2707 module_eval(<<'.,.,', 'parser.y', 5 01)2040 module_eval(<<'.,.,', 'parser.y', 517) 2708 2041 def _reduce_100(val, _values, result) 2709 2042 result = {:untyped_multiple_attr_object_block => val[0]} … … 2713 2046 .,., 2714 2047 2715 module_eval(<<'.,.,', 'parser.y', 5 05)2048 module_eval(<<'.,.,', 'parser.y', 521) 2716 2049 def _reduce_101(val, _values, result) 2717 2050 result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]} … … 2721 2054 .,., 2722 2055 2723 module_eval(<<'.,.,', 'parser.y', 5 10)2056 module_eval(<<'.,.,', 'parser.y', 526) 2724 2057 def _reduce_102(val, _values, result) 2725 2058 result = {:multiple_attr_object_block_head => val[0], :keyed_objects => val[1]} … … 2729 2062 .,., 2730 2063 2731 module_eval(<<'.,.,', 'parser.y', 5 15)2064 module_eval(<<'.,.,', 'parser.y', 531) 2732 2065 def _reduce_103(val, _values, result) 2733 @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}") 2734 result = val[0] 2735 2736 result 2737 end 2738 .,., 2739 2740 module_eval(<<'.,.,', 'parser.y', 521) 2066 result = val[0] 2067 2068 result 2069 end 2070 .,., 2071 2072 module_eval(<<'.,.,', 'parser.y', 536) 2741 2073 def _reduce_104(val, _values, result) 2742 2074 result = Array[val[0]] … … 2746 2078 .,., 2747 2079 2748 module_eval(<<'.,.,', 'parser.y', 5 25)2080 module_eval(<<'.,.,', 'parser.y', 540) 2749 2081 def _reduce_105(val, _values, result) 2750 2082 result = (val[0] << val[1]) … … 2754 2086 .,., 2755 2087 2756 module_eval(<<'.,.,', 'parser.y', 5 30)2088 module_eval(<<'.,.,', 'parser.y', 545) 2757 2089 def _reduce_106(val, _values, result) 2758 @@log .info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")2759 result = {:object_key => val[0], :object_block => val[ 1]}2760 2761 result 2762 end 2763 .,., 2764 2765 module_eval(<<'.,.,', 'parser.y', 5 36)2090 @@logger.debug("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]} at #{@filename}:#{@lineno}") 2091 result = {:object_key => val[0], :object_block => val[2]} 2092 2093 result 2094 end 2095 .,., 2096 2097 module_eval(<<'.,.,', 'parser.y', 551) 2766 2098 def _reduce_107(val, _values, result) 2767 @@log .info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")2099 @@logger.debug("object_key: [#{val[1]}] at #{@filename}:#{@lineno}") 2768 2100 result = val[1] 2769 2101 … … 2772 2104 .,., 2773 2105 2774 module_eval(<<'.,.,', 'parser.y', 5 42)2106 module_eval(<<'.,.,', 'parser.y', 557) 2775 2107 def _reduce_108(val, _values, result) 2776 2108 result = {:untyped_single_attr_object_block => val[0]} … … 2780 2112 .,., 2781 2113 2782 module_eval(<<'.,.,', 'parser.y', 5 46)2114 module_eval(<<'.,.,', 'parser.y', 561) 2783 2115 def _reduce_109(val, _values, result) 2784 2116 result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]} … … 2788 2120 .,., 2789 2121 2790 module_eval(<<'.,.,', 'parser.y', 5 51)2122 module_eval(<<'.,.,', 'parser.y', 566) 2791 2123 def _reduce_110(val, _values, result) 2792 @@log .info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")2124 @@logger.debug("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}") 2793 2125 result = {:single_attr_object_complex_head => val[0]} 2794 2126 … … 2797 2129 .,., 2798 2130 2799 module_eval(<<'.,.,', 'parser.y', 5 56)2131 module_eval(<<'.,.,', 'parser.y', 571) 2800 2132 def _reduce_111(val, _values, result) 2801 @@log .info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]},attr_vals = #{val[1]} at #{@filename}:#{@lineno}")2133 @@logger.debug("#{__FILE__}:#{__LINE__}: attr_vals = #{val[1]} at #{@filename}:#{@lineno}") 2802 2134 result = {:single_attr_object_complex_head => val[0], :attr_vals => val[1]} 2803 2135 … … 2808 2140 # reduce 112 omitted 2809 2141 2810 module_eval(<<'.,.,', 'parser.y', 5 62)2142 module_eval(<<'.,.,', 'parser.y', 577) 2811 2143 def _reduce_113(val, _values, result) 2812 @@log .info("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")2144 @@logger.debug("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}") 2813 2145 result = {:untyped_primitive_object_block => val[0]} 2814 2146 … … 2817 2149 .,., 2818 2150 2819 module_eval(<<'.,.,', 'parser.y', 5 67)2151 module_eval(<<'.,.,', 'parser.y', 582) 2820 2152 def _reduce_114(val, _values, result) 2821 @@log .info("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")2153 @@logger.debug("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}") 2822 2154 result = {:type_identifier => val[0], :untyped_primitive_object_block => val[1]} 2823 2155 … … 2826 2158 .,., 2827 2159 2828 module_eval(<<'.,.,', 'parser.y', 5 72)2160 module_eval(<<'.,.,', 'parser.y', 587) 2829 2161 def _reduce_115(val, _values, result) 2830 @@log .info("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}")2162 @@logger.debug("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}") 2831 2163 result = val[1] 2832 2164 … … 2835 2167 .,., 2836 2168 2837 module_eval(<<'.,.,', 'parser.y', 5 77)2169 module_eval(<<'.,.,', 'parser.y', 592) 2838 2170 def _reduce_116(val, _values, result) 2839 2171 result = val[0] … … 2843 2175 .,., 2844 2176 2845 module_eval(<<'.,.,', 'parser.y', 5 81)2177 module_eval(<<'.,.,', 'parser.y', 596) 2846 2178 def _reduce_117(val, _values, result) 2847 2179 result = val[0] … … 2851 2183 .,., 2852 2184 2853 module_eval(<<'.,.,', 'parser.y', 585)2185 module_eval(<<'.,.,', 'parser.y', 600) 2854 2186 def _reduce_118(val, _values, result) 2855 2187 result = val[0] … … 2859 2191 .,., 2860 2192 2861 module_eval(<<'.,.,', 'parser.y', 589)2193 module_eval(<<'.,.,', 'parser.y', 604) 2862 2194 def _reduce_119(val, _values, result) 2863 2195 result = val[0] … … 2867 2199 .,., 2868 2200 2869 module_eval(<<'.,.,', 'parser.y', 593)2201 module_eval(<<'.,.,', 'parser.y', 608) 2870 2202 def _reduce_120(val, _values, result) 2871 2203 result = val[0] … … 2875 2207 .,., 2876 2208 2877 module_eval(<<'.,.,', 'parser.y', 597)2209 module_eval(<<'.,.,', 'parser.y', 612) 2878 2210 def _reduce_121(val, _values, result) 2879 @@log .info("string_value: #{val[0]} at #{@filename}:#{@lineno}")2211 @@logger.debug("string_value: #{val[0]} at #{@filename}:#{@lineno}") 2880 2212 result = val[0] 2881 2213 … … 2884 2216 .,., 2885 2217 2886 module_eval(<<'.,.,', 'parser.y', 6 02)2218 module_eval(<<'.,.,', 'parser.y', 617) 2887 2219 def _reduce_122(val, _values, result) 2888 @@log .info("integer_value: #{val[0]} at #{@filename}:#{@lineno}")2220 @@logger.debug("integer_value: #{val[0]} at #{@filename}:#{@lineno}") 2889 2221 result = val[0] 2890 2222 … … 2893 2225 .,., 2894 2226 2895 module_eval(<<'.,.,', 'parser.y', 6 07)2227 module_eval(<<'.,.,', 'parser.y', 622) 2896 2228 def _reduce_123(val, _values, result) 2897 @@log .info("real_value: #{val[0]} at #{@filename}:#{@lineno}")2229 @@logger.debug("real_value: #{val[0]} at #{@filename}:#{@lineno}") 2898 2230 result = val[0] 2899 2231 … … 2902 2234 .,., 2903 2235 2904 module_eval(<<'.,.,', 'parser.y', 6 12)2236 module_eval(<<'.,.,', 'parser.y', 627) 2905 2237 def _reduce_124(val, _values, result) 2906 @@log .info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")2238 @@logger.debug("boolean_value: #{val[0]} at #{@filename}:#{@lineno}") 2907 2239 result = val[0] 2908 2240 … … 2911 2243 .,., 2912 2244 2913 module_eval(<<'.,.,', 'parser.y', 6 17)2245 module_eval(<<'.,.,', 'parser.y', 632) 2914 2246 def _reduce_125(val, _values, result) 2915 @@log .info("character_value: #{val[0]} at #{@filename}:#{@lineno}")2247 @@logger.debug("character_value: #{val[0]} at #{@filename}:#{@lineno}") 2916 2248 result = val[0] 2917 2249 … … 2920 2252 .,., 2921 2253 2922 module_eval(<<'.,.,', 'parser.y', 6 22)2254 module_eval(<<'.,.,', 'parser.y', 637) 2923 2255 def _reduce_126(val, _values, result) 2924 @@log .info("date_value: #{val[0]} at #{@filename}:#{@lineno}")2256 @@logger.debug("date_value: #{val[0]} at #{@filename}:#{@lineno}") 2925 2257 result = val[0] 2926 2258 … … 2929 2261 .,., 2930 2262 2931 module_eval(<<'.,.,', 'parser.y', 6 27)2263 module_eval(<<'.,.,', 'parser.y', 642) 2932 2264 def _reduce_127(val, _values, result) 2933 @@log .info("time_value: #{val[0]} at #{@filename}:#{@lineno}")2265 @@logger.debug("time_value: #{val[0]} at #{@filename}:#{@lineno}") 2934 2266 result = val[0] 2935 2267 … … 2938 2270 .,., 2939 2271 2940 module_eval(<<'.,.,', 'parser.y', 6 32)2272 module_eval(<<'.,.,', 'parser.y', 647) 2941 2273 def _reduce_128(val, _values, result) 2942 @@log .info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")2274 @@logger.debug("date_time_value: #{val[0]} at #{@filename}:#{@lineno}") 2943 2275 result = val[0] 2944 2276 … … 2947 2279 .,., 2948 2280 2949 module_eval(<<'.,.,', 'parser.y', 6 37)2281 module_eval(<<'.,.,', 'parser.y', 652) 2950 2282 def _reduce_129(val, _values, result) 2951 @@log .info("duration_value: #{val[0]} at #{@filename}:#{@lineno}")2283 @@logger.debug("duration_value: #{val[0]} at #{@filename}:#{@lineno}") 2952 2284 result = val[0] 2953 2285 … … 2956 2288 .,., 2957 2289 2958 module_eval(<<'.,.,', 'parser.y', 6 42)2290 module_eval(<<'.,.,', 'parser.y', 657) 2959 2291 def _reduce_130(val, _values, result) 2960 @@log .info("uri_value: #{val[0]} at #{@filename}:#{@lineno}")2292 @@logger.debug("uri_value: #{val[0]} at #{@filename}:#{@lineno}") 2961 2293 result = val[0] 2962 2294 … … 2995 2327 # reduce 145 omitted 2996 2328 2997 module_eval(<<'.,.,', 'parser.y', 6 65)2329 module_eval(<<'.,.,', 'parser.y', 680) 2998 2330 def _reduce_146(val, _values, result) 2999 @@log .info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")2331 @@logger.debug("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}") 3000 2332 result = val[0] 3001 2333 … … 3004 2336 .,., 3005 2337 3006 module_eval(<<'.,.,', 'parser.y', 6 70)2338 module_eval(<<'.,.,', 'parser.y', 685) 3007 2339 def _reduce_147(val, _values, result) 3008 @@log .info("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")2340 @@logger.debug("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}") 3009 2341 result = val[0] 3010 2342 … … 3013 2345 .,., 3014 2346 3015 module_eval(<<'.,.,', 'parser.y', 6 76)2347 module_eval(<<'.,.,', 'parser.y', 691) 3016 2348 def _reduce_148(val, _values, result) 3017 @@log .info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")2349 @@logger.debug("V_STRING: #{val[0]} at #{@filename}:#{@lineno}") 3018 2350 result = val[0] 3019 2351 … … 3028 2360 # reduce 151 omitted 3029 2361 3030 module_eval(<<'.,.,', 'parser.y', 686)2362 module_eval(<<'.,.,', 'parser.y', 701) 3031 2363 def _reduce_152(val, _values, result) 3032 2364 begin … … 3041 2373 .,., 3042 2374 3043 module_eval(<<'.,.,', 'parser.y', 695)2375 module_eval(<<'.,.,', 'parser.y', 710) 3044 2376 def _reduce_153(val, _values, result) 3045 2377 begin … … 3054 2386 .,., 3055 2387 3056 module_eval(<<'.,.,', 'parser.y', 7 04)2388 module_eval(<<'.,.,', 'parser.y', 719) 3057 2389 def _reduce_154(val, _values, result) 3058 2390 begin … … 3091 2423 # reduce 166 omitted 3092 2424 3093 module_eval(<<'.,.,', 'parser.y', 7 30)2425 module_eval(<<'.,.,', 'parser.y', 745) 3094 2426 def _reduce_167(val, _values, result) 3095 2427 begin … … 3104 2436 .,., 3105 2437 3106 module_eval(<<'.,.,', 'parser.y', 7 39)2438 module_eval(<<'.,.,', 'parser.y', 754) 3107 2439 def _reduce_168(val, _values, result) 3108 2440 begin … … 3117 2449 .,., 3118 2450 3119 module_eval(<<'.,.,', 'parser.y', 7 48)2451 module_eval(<<'.,.,', 'parser.y', 763) 3120 2452 def _reduce_169(val, _values, result) 3121 2453 begin … … 3154 2486 # reduce 181 omitted 3155 2487 3156 module_eval(<<'.,.,', 'parser.y', 7 73)2488 module_eval(<<'.,.,', 'parser.y', 788) 3157 2489 def _reduce_182(val, _values, result) 3158 2490 result = true … … 3162 2494 .,., 3163 2495 3164 module_eval(<<'.,.,', 'parser.y', 7 77)2496 module_eval(<<'.,.,', 'parser.y', 792) 3165 2497 def _reduce_183(val, _values, result) 3166 2498 result = false … … 3184 2516 # reduce 190 omitted 3185 2517 3186 # reduce 191 omitted 2518 module_eval(<<'.,.,', 'parser.y', 807) 2519 def _reduce_191(val, _values, result) 2520 result = val[0] 2521 2522 result 2523 end 2524 .,., 3187 2525 3188 2526 # reduce 192 omitted … … 3262 2600 # reduce 229 omitted 3263 2601 3264 module_eval(<<'.,.,', 'parser.y', 8 40)2602 module_eval(<<'.,.,', 'parser.y', 858) 3265 2603 def _reduce_230(val, _values, result) 3266 @@log .info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")2604 @@logger.debug("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}") 3267 2605 result = val[0] 3268 2606 … … 3295 2633 # reduce 242 omitted 3296 2634 3297 module_eval(<<'.,.,', 'parser.y', 8 60)2635 module_eval(<<'.,.,', 'parser.y', 878) 3298 2636 def _reduce_243(val, _values, result) 3299 @@log .info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")2637 @@logger.debug("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}") 3300 2638 result = val[0] 3301 2639 … … 3310 2648 # reduce 246 omitted 3311 2649 3312 module_eval(<<'.,.,', 'parser.y', 8 70)2650 module_eval(<<'.,.,', 'parser.y', 888) 3313 2651 def _reduce_247(val, _values, result) 3314 @@log .info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")2652 @@logger.debug("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}") 3315 2653 result = val[0] 3316 2654 … … 3399 2737 # reduce 287 omitted 3400 2738 3401 module_eval(<<'.,.,', 'parser.y', 9 40)2739 module_eval(<<'.,.,', 'parser.y', 958) 3402 2740 def _reduce_288(val, _values, result) 3403 @@log .info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")3404 3405 result 3406 end 3407 .,., 3408 3409 module_eval(<<'.,.,', 'parser.y', 9 44)2741 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 2742 2743 result 2744 end 2745 .,., 2746 2747 module_eval(<<'.,.,', 'parser.y', 962) 3410 2748 def _reduce_289(val, _values, result) 3411 @@log .info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")3412 3413 result 3414 end 3415 .,., 3416 3417 module_eval(<<'.,.,', 'parser.y', 9 55)2749 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 2750 2751 result 2752 end 2753 .,., 2754 2755 module_eval(<<'.,.,', 'parser.y', 973) 3418 2756 def _reduce_290(val, _values, result) 3419 2757 result = Range.new(1,1) … … 3423 2761 .,., 3424 2762 3425 module_eval(<<'.,.,', 'parser.y', 9 59)2763 module_eval(<<'.,.,', 'parser.y', 977) 3426 2764 def _reduce_291(val, _values, result) 3427 2765 result = val[3] … … 3431 2769 .,., 3432 2770 3433 module_eval(<<'.,.,', 'parser.y', 9 64)2771 module_eval(<<'.,.,', 'parser.y', 982) 3434 2772 def _reduce_292(val, _values, result) 3435 2773 begin … … 3444 2782 .,., 3445 2783 3446 module_eval(<<'.,.,', 'parser.y', 9 73)2784 module_eval(<<'.,.,', 'parser.y', 991) 3447 2785 def _reduce_293(val, _values, result) 3448 2786 begin … … 3458 2796 .,., 3459 2797 3460 module_eval(<<'.,.,', 'parser.y', 984)2798 module_eval(<<'.,.,', 'parser.y', 1002) 3461 2799 def _reduce_294(val, _values, result) 3462 2800 result = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new … … 3482 2820 # reduce 302 omitted 3483 2821 3484 module_eval(<<'.,.,', 'parser.y', 998)2822 module_eval(<<'.,.,', 'parser.y', 1016) 3485 2823 def _reduce_303(val, _values, result) 3486 2824 result = val[0] … … 3490 2828 .,., 3491 2829 3492 module_eval(<<'.,.,', 'parser.y', 10 02)2830 module_eval(<<'.,.,', 'parser.y', 1020) 3493 2831 def _reduce_304(val, _values, result) 3494 2832 result = val[0] … … 3500 2838 # reduce 305 omitted 3501 2839 3502 module_eval(<<'.,.,', 'parser.y', 10 09)2840 module_eval(<<'.,.,', 'parser.y', 1027) 3503 2841 def _reduce_306(val, _values, result) 3504 2842 result = val[3] … … 3600 2938 # reduce 352 omitted 3601 2939 3602 module_eval(<<'.,.,', 'parser.y', 10 79)2940 module_eval(<<'.,.,', 'parser.y', 1097) 3603 2941 def _reduce_353(val, _values, result) 3604 2942 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true) … … 3608 2946 .,., 3609 2947 3610 module_eval(<<'.,.,', 'parser.y', 1 083)2948 module_eval(<<'.,.,', 'parser.y', 1101) 3611 2949 def _reduce_354(val, _values, result) 3612 2950 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false) … … 3616 2954 .,., 3617 2955 3618 module_eval(<<'.,.,', 'parser.y', 1 087)2956 module_eval(<<'.,.,', 'parser.y', 1105) 3619 2957 def _reduce_355(val, _values, result) 3620 2958 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,:false_valid => false) … … 3624 2962 .,., 3625 2963 3626 module_eval(<<'.,.,', 'parser.y', 1 091)2964 module_eval(<<'.,.,', 'parser.y', 1109) 3627 2965 def _reduce_356(val, _values, result) 3628 2966 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false,:false_valid => true) … … 3632 2970 .,., 3633 2971 3634 module_eval(<<'.,.,', 'parser.y', 1 096)2972 module_eval(<<'.,.,', 'parser.y', 1114) 3635 2973 def _reduce_357(val, _values, result) 3636 2974 result = val[0] … … 3640 2978 .,., 3641 2979 3642 module_eval(<<'.,.,', 'parser.y', 11 00)2980 module_eval(<<'.,.,', 'parser.y', 1118) 3643 2981 def _reduce_358(val, _values, result) 3644 2982 raise 'Not implemented yet' … … 3648 2986 .,., 3649 2987 3650 module_eval(<<'.,.,', 'parser.y', 11 04)2988 module_eval(<<'.,.,', 'parser.y', 1122) 3651 2989 def _reduce_359(val, _values, result) 3652 2990 raise 'Not implemented yet' … … 3666 3004 # reduce 364 omitted 3667 3005 3668 module_eval(<<'.,.,', 'parser.y', 11 16)3006 module_eval(<<'.,.,', 'parser.y', 1134) 3669 3007 def _reduce_365(val, _values, result) 3670 3008 @in_interval = false 3671 @@log .info("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}")3672 3673 result 3674 end 3675 .,., 3676 3677 module_eval(<<'.,.,', 'parser.y', 11 23)3009 @@logger.debug("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 3010 3011 result 3012 end 3013 .,., 3014 3015 module_eval(<<'.,.,', 'parser.y', 1141) 3678 3016 def _reduce_366(val, _values, result) 3679 3017 result = val[0] … … 3683 3021 .,., 3684 3022 3685 module_eval(<<'.,.,', 'parser.y', 11 27)3023 module_eval(<<'.,.,', 'parser.y', 1145) 3686 3024 def _reduce_367(val, _values, result) 3687 3025 result = val[0] … … 3691 3029 .,., 3692 3030 3693 # reduce 368 omitted 3031 module_eval(<<'.,.,', 'parser.y', 1151) 3032 def _reduce_368(val, _values, result) 3033 @@logger.debug("#{__FILE__}:#{__LINE__}, START_TERM_CODE_CONSTRAINT = #{val[0]} at #{@filename}") 3034 @@logger.debug("#{__FILE__}:#{__LINE__}, term_code_body = #{val[1]}") 3035 @@logger.debug("#{__FILE__}:#{__LINE__}, END_TERM_CODE_CONSTRAINT = #{val[2]}") 3036 result = val[1] 3037 3038 result 3039 end 3040 .,., 3694 3041 3695 3042 # reduce 369 omitted … … 3699 3046 # reduce 371 omitted 3700 3047 3701 module_eval(<<'.,.,', 'parser.y', 11 42)3048 module_eval(<<'.,.,', 'parser.y', 1167) 3702 3049 def _reduce_372(val, _values, result) 3703 3050 result = val[0] … … 3707 3054 .,., 3708 3055 3709 module_eval(<<'.,.,', 'parser.y', 11 47)3056 module_eval(<<'.,.,', 'parser.y', 1172) 3710 3057 def _reduce_373(val, _values, result) 3711 3058 result = val[0] … … 3715 3062 .,., 3716 3063 3717 module_eval(<<'.,.,', 'parser.y', 11 51)3064 module_eval(<<'.,.,', 'parser.y', 1176) 3718 3065 def _reduce_374(val, _values, result) 3719 @@log .info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")3066 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}") 3720 3067 result = val[0] 3721 3068 … … 3724 3071 .,., 3725 3072 3726 module_eval(<<'.,.,', 'parser.y', 11 62)3073 module_eval(<<'.,.,', 'parser.y', 1187) 3727 3074 def _reduce_375(val, _values, result) 3728 3075 result = val[0] -
ruby/branches/0.5/lib/adl_parser/lib/parser.y
r116 r290 40 40 41 41 archetype_id = val[0][:archetype_id] 42 parent_archtype_id = val[1][:parent_archtype_id] if val[1] 42 43 adl_version = val[0][:arch_head][:arch_meta_data][:adl_version] 43 44 concept = val[2] … … 45 46 archetype = OpenEHR::AM::Archetype::ARCHETYPE.create( 46 47 :archetype_id => archetype_id, 48 :parent_archtype_id => parent_archtype_id, 47 49 :adl_version => adl_version, 48 50 :concept => concept, … … 53 55 archetype.original_language = language 54 56 end 55 @@log .info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")57 @@logger.debug("#{__FILE__}:#{__LINE__}: archetype = #{archetype.to_yaml} at #{@filename}:#{@lineno}") 56 58 result = archetype 57 59 } … … 104 106 arch_specialisation: #-- empty is ok 105 107 | SYM_SPECIALIZE V_ARCHETYPE_ID 108 { 109 result = {:parent_archtype_id => val[1]} 110 } 106 111 | SYM_SPECIALIZE error 107 112 … … 150 155 { 151 156 assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT)} 152 @@log .info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}")157 @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0]} at #{@filename}:#{@lineno}") 153 158 result = val[0] 154 159 } … … 201 206 202 207 #------------------------- node types ----------------------- 203 204 c_object: v_c_domain_type 205 { 206 result = val[0] 207 } 208 | c_complex_object 209 { 210 @@log.info("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}") 208 ### http://www.openehr.org/svn/ref_impl_eiffel/TRUNK/components/adl_parser/src/syntax/cadl/parser/cadl_validator.html 209 ### c_object: c_complex_object 210 ### | archetype_internal_ref 211 ### | archetype_slot 212 ### | constraint_ref 213 ### | c_code_phrase 214 ### | c_ordinal 215 ### | c_primitive_object 216 ### | V_C_DOMAIN_TYPE 217 ### | ERR_C_DOMAIN_TYPE 218 ### | error 219 c_object: c_complex_object 220 { 221 @@logger.debug("#{__FILE__}:#{__LINE__}: c_complex_object = #{val[0].inspect} at #{@filename}:#{@lineno}") 211 222 result = val[0] 212 223 } … … 241 252 result = val[0] 242 253 } 254 | v_c_domain_type 255 { 256 result = val[0] 257 } 258 243 259 # | v_c_domain_type 244 260 # | V_C_DOMAIN_TYPE … … 297 313 c_primitive: c_integer 298 314 { 299 @@log .info("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")315 @@logger.debug("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}") 300 316 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.create do |c_integer| 301 317 c_integer.list … … 306 322 | c_real 307 323 { 308 @@log .info("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}")324 @@logger.debug("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}") 309 325 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new 310 326 } 311 327 | c_date 312 328 { 313 @@log .info("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}")329 @@logger.debug("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}") 314 330 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new 315 331 } 316 332 | c_time 317 333 { 318 @@log .info("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}")334 @@logger.debug("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}") 319 335 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new 320 336 } 321 337 | c_date_time 322 338 { 323 @@log .info("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}")339 @@logger.debug("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}") 324 340 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new 325 341 } 326 342 | c_duration 327 343 { 328 @@log .info("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}")344 @@logger.debug("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}") 329 345 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new 330 346 } 331 347 | c_string 332 348 { 333 @@log .info("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}")349 @@logger.debug("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}") 334 350 result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new 335 351 } … … 337 353 { 338 354 assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN)} 339 @@log .info("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}")355 @@logger.debug("#{__FILE__}:#{__LINE__}: c_boolean = #{val[0]} at #{@filename}:#{@lineno}") 340 356 result = val[0] 341 357 } … … 377 393 c_attr_head: V_ATTRIBUTE_IDENTIFIER c_existence 378 394 { 379 @@log .info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}")395 @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}") 380 396 result = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new( 381 397 :rm_attribute_name => val[0], … … 387 403 { 388 404 assert_at(__FILE__,__LINE__){ val[2].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY) } 389 @@log .info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}")405 @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER: #{val[0]}, c_existence = #{val[1]}, c_cardinality = #{val[2]} at #{@filename}") 390 406 result = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new( 391 407 :rm_attribute_name => val[0], … … 469 485 attr_val: attr_id SYM_EQ object_block 470 486 { 471 @@log .info("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")487 @@logger.debug("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]} at #{@filename}:#{@lineno}") 472 488 result = {:attr_id => val[0], :object_block => val[2]} 473 489 } … … 475 491 attr_id: V_ATTRIBUTE_IDENTIFIER 476 492 { 477 @@log .info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")493 @@logger.debug("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}") 478 494 result = val[0] 479 495 } … … 514 530 multiple_attr_object_block_head: SYM_START_DBLOCK 515 531 { 516 @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")517 532 result = val[0] 518 533 } … … 529 544 keyed_object: object_key SYM_EQ object_block 530 545 { 531 @@log .info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")532 result = {:object_key => val[0], :object_block => val[ 1]}546 @@logger.debug("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]} at #{@filename}:#{@lineno}") 547 result = {:object_key => val[0], :object_block => val[2]} 533 548 } 534 549 535 550 object_key: Left_bracket_code simple_value Right_bracket_code 536 551 { 537 @@log .info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")552 @@logger.debug("object_key: [#{val[1]}] at #{@filename}:#{@lineno}") 538 553 result = val[1] 539 554 } … … 548 563 } 549 564 550 untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # <>551 { 552 @@log .info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")565 untyped_single_attr_object_block: single_attr_object_complex_head SYM_END_DBLOCK # > 566 { 567 @@logger.debug("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}") 553 568 result = {:single_attr_object_complex_head => val[0]} 554 569 } 555 570 | single_attr_object_complex_head attr_vals SYM_END_DBLOCK 556 571 { 557 @@log .info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]},attr_vals = #{val[1]} at #{@filename}:#{@lineno}")572 @@logger.debug("#{__FILE__}:#{__LINE__}: attr_vals = #{val[1]} at #{@filename}:#{@lineno}") 558 573 result = {:single_attr_object_complex_head => val[0], :attr_vals => val[1]} 559 574 } … … 561 576 primitive_object_block: untyped_primitive_object_block 562 577 { 563 @@log .info("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")578 @@logger.debug("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}") 564 579 result = {:untyped_primitive_object_block => val[0]} 565 580 } 566 581 | type_identifier untyped_primitive_object_block 567 582 { 568 @@log .info("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")583 @@logger.debug("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}") 569 584 result = {:type_identifier => val[0], :untyped_primitive_object_block => val[1]} 570 585 } 571 586 untyped_primitive_object_block: SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK 572 587 { 573 @@log .info("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}")588 @@logger.debug("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}") 574 589 result = val[1] 575 590 } … … 596 611 simple_value: string_value 597 612 { 598 @@log .info("string_value: #{val[0]} at #{@filename}:#{@lineno}")613 @@logger.debug("string_value: #{val[0]} at #{@filename}:#{@lineno}") 599 614 result = val[0] 600 615 } 601 616 | integer_value 602 617 { 603 @@log .info("integer_value: #{val[0]} at #{@filename}:#{@lineno}")618 @@logger.debug("integer_value: #{val[0]} at #{@filename}:#{@lineno}") 604 619 result = val[0] 605 620 } 606 621 | real_value 607 622 { 608 @@log .info("real_value: #{val[0]} at #{@filename}:#{@lineno}")623 @@logger.debug("real_value: #{val[0]} at #{@filename}:#{@lineno}") 609 624 result = val[0] 610 625 } 611 626 | boolean_value 612 627 { 613 @@log .info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")628 @@logger.debug("boolean_value: #{val[0]} at #{@filename}:#{@lineno}") 614 629 result = val[0] 615 630 } 616 631 | character_value 617 632 { 618 @@log .info("character_value: #{val[0]} at #{@filename}:#{@lineno}")633 @@logger.debug("character_value: #{val[0]} at #{@filename}:#{@lineno}") 619 634 result = val[0] 620 635 } 621 636 | date_value 622 637 { 623 @@log .info("date_value: #{val[0]} at #{@filename}:#{@lineno}")638 @@logger.debug("date_value: #{val[0]} at #{@filename}:#{@lineno}") 624 639 result = val[0] 625 640 } 626 641 | time_value 627 642 { 628 @@log .info("time_value: #{val[0]} at #{@filename}:#{@lineno}")643 @@logger.debug("time_value: #{val[0]} at #{@filename}:#{@lineno}") 629 644 result = val[0] 630 645 } 631 646 | date_time_value 632 647 { 633 @@log .info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")648 @@logger.debug("date_time_value: #{val[0]} at #{@filename}:#{@lineno}") 634 649 result = val[0] 635 650 } 636 651 | duration_value 637 652 { 638 @@log .info("duration_value: #{val[0]} at #{@filename}:#{@lineno}")653 @@logger.debug("duration_value: #{val[0]} at #{@filename}:#{@lineno}") 639 654 result = val[0] 640 655 } 641 656 | uri_value 642 657 { 643 @@log .info("uri_value: #{val[0]} at #{@filename}:#{@lineno}")658 @@logger.debug("uri_value: #{val[0]} at #{@filename}:#{@lineno}") 644 659 result = val[0] 645 660 } … … 664 679 type_identifier: V_TYPE_IDENTIFIER 665 680 { 666 @@log .info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")681 @@logger.debug("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}") 667 682 result = val[0] 668 683 } 669 684 | V_GENERIC_TYPE_IDENTIFIER 670 685 { 671 @@log .info("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")686 @@logger.debug("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}") 672 687 result = val[0] 673 688 } … … 675 690 string_value: V_STRING 676 691 { 677 @@log .info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")692 @@logger.debug("V_STRING: #{val[0]} at #{@filename}:#{@lineno}") 678 693 result = val[0] 679 694 } … … 790 805 791 806 date_value: V_ISO8601_EXTENDED_DATE 807 { 808 result = val[0] 809 } 792 810 793 811 date_list_value: date_value Comma_code date_value … … 839 857 duration_value: V_ISO8601_DURATION 840 858 { 841 @@log .info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")859 @@logger.debug("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}") 842 860 result = val[0] 843 861 } … … 859 877 term_code: V_QUALIFIED_TERM_CODE_REF 860 878 { 861 @@log .info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")879 @@logger.debug("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}") 862 880 result = val[0] 863 881 } … … 869 887 uri_value: V_URI 870 888 { 871 @@log .info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")889 @@logger.debug("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}") 872 890 result = val[0] 873 891 } … … 939 957 path_segment: V_ATTRIBUTE_IDENTIFIER V_LOCAL_TERM_CODE_REF 940 958 { 941 @@log .info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")959 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 942 960 } 943 961 | V_ATTRIBUTE_IDENTIFIER 944 962 { 945 @@log .info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")963 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}") 946 964 } 947 965 … … 1116 1134 { 1117 1135 @in_interval = false 1118 @@log .info("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}")1136 @@logger.debug("#{__FILE__}:#{__LINE__}, #{val[0]}|#{val[2]} at #{@filename}") 1119 1137 } 1120 1138 … … 1129 1147 } 1130 1148 1131 # term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body Right_bracket_code1149 # [[a-zA-Z0-9\(\)\._\-]+::[ \t\n]* [[a-zA-Z0-9\._\-]*[ \t]*] 1132 1150 term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT 1151 { 1152 @@logger.debug("#{__FILE__}:#{__LINE__}, START_TERM_CODE_CONSTRAINT = #{val[0]} at #{@filename}") 1153 @@logger.debug("#{__FILE__}:#{__LINE__}, term_code_body = #{val[1]}") 1154 @@logger.debug("#{__FILE__}:#{__LINE__}, END_TERM_CODE_CONSTRAINT = #{val[2]}") 1155 result = val[1] 1156 } 1157 1158 1133 1159 term_code_body: # empty 1134 1160 | TERM_CODE 1135 1161 | term_code_body TERM_CODE 1136 ### term_code_constraint_section: START_TERM_CODE_CONSTRAINT term_code_body END_TERM_CODE_CONSTRAINT1137 1162 ### term_code_body: TERM_CODE 1138 1163 ### | term_code_body TERM_CODE … … 1150 1175 | V_ATTRIBUTE_IDENTIFIER 1151 1176 { 1152 @@log .info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")1177 @@logger.debug("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}") 1153 1178 result = val[0] 1154 1179 } … … 1171 1196 $:.unshift File.join(File.dirname(__FILE__)) 1172 1197 require 'logger' 1173 #require 'lib/util.rb' 1174 #require 'lib/scanner.rb' 1175 require 'lib/adl_parser.rb' 1198 require 'yaml' 1176 1199 require 'rubygems' 1200 require 'adl_parser.rb' 1177 1201 require 'am.rb' 1202 require 'rm.rb' 1178 1203 $DEBUG = false 1179 1204 … … 1189 1214 1190 1215 if $DEBUG 1191 @@log = Logger.new('log/parser.log','daily')1192 @@log .level = Logger::INFO1216 @@logger = Logger.new('log/parser.log','daily') 1217 @@logger.level = Logger::DEBUG 1193 1218 else 1194 @@log = Logger.new(STDOUT)1195 @@log .level = Logger::WARN1219 @@logger = Logger.new(STDOUT) 1220 @@logger.level = Logger::WARN 1196 1221 end 1197 1222 1198 @@dadl_scanner = OpenEHR::ADL::Scanner::DADL::RootScanner.new1199 @@cadl_scanner = OpenEHR::ADL::Scanner::CADL::RootScanner.new1200 1223 1201 1224 ###----------/* keywords */ --------------------------------------------- … … 1257 1280 ###----------/* Scanner */ ----------------------------------------------- 1258 1281 1282 1259 1283 def scan 1284 @@logger.debug("#{__FILE__}:#{__LINE__}: Entering scan at #{@filename}:#{@lineno}:") 1285 scanner = OpenEHR::ADL::Scanner::ADLScanner.new(@adl_type, @filename) 1286 1260 1287 until @data.nil? do 1261 case @adl_type.last 1262 when :adl 1263 @data = scan_adl(@data) do |sym, val| 1288 @data = scanner.scan(@data) do |sym, val| 1264 1289 yield sym, val 1265 end1266 when :dadl1267 @data = scan_dadl(@data) do |sym, val|1268 yield sym, val1269 end1270 when :cadl1271 @data = scan_cadl(@data) do |sym, val|1272 yield sym, val1273 end1274 when :regexp1275 @data = scan_regexp(@data) do |sym, val|1276 yield sym, val1277 end1278 else1279 raise1280 1290 end 1281 1291 @data = $' # variable $' receives the string after the match … … 1284 1294 yield false, '$' 1285 1295 end # of scan 1286 1287 def scan_adl(data)1288 until data.nil? do1289 case @adl_type.last1290 when :adl1291 # puts "Entering scan_adl"1292 case data1293 when /\A\n/ # carriage return1294 @lineno += 11295 ;1296 when /\A[ \t\r\f]+/ #just drop it1297 ;1298 when /\A--.*\n/ # single line comment1299 @lineno += 11300 @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: COMMENT = #{$&} at #{@filename}:#{@lineno}")1301 ;1302 when /\Adescription/ # description1303 yield :SYM_DESCRIPTION, :SYM_DESCRIPTION1304 when /\Adefinition/ # definition1305 yield :SYM_DEFINITION, :SYM_DEFINITION1306 # @adl_type.push(:cadl)1307 ###----------/* symbols */ -------------------------------------------------1308 when /\A[A-Z][a-zA-Z0-9_]*/1309 yield :V_TYPE_IDENTIFIER, $&1310 when /\A[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z0-9]+/ #V_ARCHETYPE_ID1311 yield :V_ARCHETYPE_ID, $&1312 when /\A[a-z][a-zA-Z0-9_]*/1313 # word = $&.downcase1314 word = $&1315 if @@adl_reserved[word]1316 @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: @@adl_reserved = #{@@adl_reserved[word]} at #{@filename}:#{@lineno}")1317 yield @@adl_reserved[word], @@adl_reserved[word]1318 elsif #/\A[A-Z][a-zA-Z0-9_]*/1319 @@log.info("#{__FILE__}:#{__LINE__}: scan_adl: V_ATTRIBUTE_IDENTIFIER = #{$&} at #{@filename}:#{@lineno}")1320 yield :V_ATTRIBUTE_IDENTIFIER, $&1321 end1322 when /\A\=/ # =1323 yield :SYM_EQ, :SYM_EQ1324 when /\A\>=/ # >=1325 yield :SYM_GE, :SYM_GE1326 when /\A\<=/ # <=1327 yield :SYM_LE, :SYM_LE1328 when /\A\</ # <1329 if @in_interval1330 # @start_block_received = false1331 yield :SYM_LT, :SYM_LT1332 else1333 # @start_block_received = true1334 @adl_type.push(:dadl)1335 yield :SYM_START_DBLOCK, $&1336 end1337 when /\A\>/ # >1338 if @in_interval1339 yield :SYM_GT, :SYM_GT1340 else1341 adl_type = @adl_type.pop1342 # puts "Escaping #{adl_type}"1343 assert_at(__FILE__,__LINE__){adl_type == :dadl}1344 yield :SYM_END_DBLOCK, :SYM_END_DBLOCK1345 end1346 when /\A\{/ # {1347 @adl_type.push(:cadl)1348 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")1349 yield :SYM_START_CBLOCK, :SYM_START_CBLOCK1350 when /\A\}/ # }1351 adl_type = @adl_type.pop1352 # puts "Escaping #{adl_type}"1353 assert_at(__FILE__,__LINE__){adl_type == :cadl}1354 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")1355 yield :SYM_END_CBLOCK, $&1356 when /\A\-/ # -1357 yield :Minus_code, :Minus_code1358 when /\A\+/ # +1359 yield :Plus_code, :Plus_code1360 when /\A\*/ # *1361 yield :Star_code, :Star_code1362 when /\A\// # /1363 yield :Slash_code, :Slash_code1364 when /\A\^/ # ^1365 yield :Caret_code, :Caret_code1366 when /\A\=/ # =1367 yield :Equal_code, :Equal_code1368 when /\A\.\.\./ # ...1369 yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE1370 when /\A\.\./ # ..1371 yield :SYM_ELLIPSIS, :SYM_ELLIPSIS1372 when /\A\./ # .1373 yield :Dot_code, :Dot_code1374 when /\A\;/ # ;1375 yield :Semicolon_code, :Semicolon_code1376 when /\A\,/ # ,1377 yield :Comma_code, :Comma_code1378 when /\A\:/ # :1379 yield :Colon_code, :Colon_code1380 when /\A\!/ # !1381 yield :Exclamation_code, :Exclamation_code1382 when /\A\(/ # (1383 yield :Left_parenthesis_code, :Left_parenthesis_code1384 when /\A\)/ # )1385 yield :Right_parenthesis_code, :Right_parenthesis_code1386 when /\A\$/ # $1387 yield :Dollar_code, :Dollar_code1388 when /\A\?\?/ # ??1389 yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN1390 when /\A\?/ # ?1391 yield :Question_mark_code, :Question_mark_code1392 when /\A[0-9]+\.[0-9]+(\.[0-9]+)*/ # ?1393 yield :V_VERSION_STRING, :V_VERSION_STRING1394 when /\A\|/ # |1395 if @in_interval1396 @in_interval = false1397 else1398 @in_interval = true1399 end1400 yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM1401 when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/1402 # when /\A\[[a-zA-Z0-9()\._-]+\:\:[a-zA-Z0-9\._-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]1403 yield :V_QUALIFIED_TERM_CODE_REF, $&1404 when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF1405 yield :V_LOCAL_TERM_CODE_REF, $&1406 when /\A\[/ # [1407 yield :Left_bracket_code, :Left_bracket_code1408 when /\A\]/ # ]1409 yield :Right_bracket_code, :Right_bracket_code1410 1411 when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF1412 yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&1413 when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE1414 yield :V_LOCAL_CODE, $&1415 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-1416 yield :V_ISO8601_EXTENDED_DATE_TIME, $&1417 when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]1418 yield :V_ISO8601_EXTENDED_TIME, $&1419 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD1420 yield :V_ISO8601_EXTENDED_DATE, $&1421 when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER1422 yield :V_GENERIC_TYPE_IDENTIFIER, $&1423 when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER1424 yield :V_INTEGER, $&1425 when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL1426 yield :V_REAL, $&1427 # when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING1428 when /\A"([^"]*)"/m #V_STRING1429 yield :V_STRING, $11430 when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI1431 yield :V_URI, $&1432 when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS1433 yield :V_ISO8601_DURATION, $&1434 when /\A\S/ #UTF8CHAR1435 yield :UTF8CHAR, $&1436 end1437 data = $' # variable $' receives the string after the match1438 when :dadl1439 # puts "Entering scan_dadl"1440 data = scan_dadl(data) do |sym, val|1441 yield sym, val1442 end1443 when :cadl1444 # puts "Entering scan_cadl"1445 data = scan_cadl(data) do |sym, val|1446 yield sym, val1447 end1448 when :regexp1449 # puts "Entering scan_regexp"1450 data = scan_regexp(data) do |sym, val|1451 yield sym, val1452 end1453 when :term_constraint1454 # puts "Entering scan_term_constraint"1455 data = scan_term_constraint(data) do |sym, val|1456 yield sym, val1457 end1458 else1459 raise1460 end1461 end1462 end # scan_adl1463 1464 1465 def scan_cadl(data)1466 until data.nil? do1467 case @adl_type.last1468 when :cadl1469 # puts "Entering scan_cadl"1470 case scanned = @@cadl_scanner.parse(data)1471 when Yaparc::Result::OK1472 if scanned.value[0] == :START_V_C_DOMAIN_TYPE_BLOCK1473 @in_c_domain_type = true1474 @adl_type.push(:dadl)1475 yield scanned.value1476 else1477 yield scanned.value1478 end1479 data = scanned.input1480 end1481 1482 case data1483 when /\A\n/ # carriage return1484 @lineno += 11485 ;1486 when /\A[ \t\r\f]+/ #just drop it1487 ;1488 when /\A--.*\n/ # single line comment1489 @lineno += 11490 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")1491 ;1492 ###----------/* symbols */ -------------------------------------------------1493 when /\A\=/ # =1494 yield :SYM_EQ, :SYM_EQ1495 when /\A\>=/ # >=1496 yield :SYM_GE, :SYM_GE1497 when /\A\<=/ # <=1498 yield :SYM_LE, :SYM_LE1499 ### when /\A[A-Z][a-zA-Z0-9_]*[ \n]*\</ # V_C_DOMAIN_TYPE1500 ### @in_c_domain_type = true1501 ### @adl_type.push(:dadl)1502 ### yield :START_V_C_DOMAIN_TYPE_BLOCK, $&1503 when /\A\</ # <1504 if @in_interval1505 yield :SYM_LT, :SYM_LT1506 else1507 @adl_type.push(:dadl)1508 yield :SYM_START_DBLOCK, $&1509 end1510 when /\A\>/ # >1511 if @in_interval1512 yield :SYM_GT, :SYM_GT1513 else1514 adl_type = @adl_type.pop1515 # puts "Escaping #{adl_type}"1516 assert_at(__FILE__,__LINE__){adl_type == :dadl}1517 yield :SYM_END_DBLOCK, :SYM_END_DBLOCK1518 end1519 when /\A\-/ # -1520 yield :Minus_code, :Minus_code1521 when /\A\+/ # +1522 yield :Plus_code, :Plus_code1523 when /\A\*/ # *1524 yield :Star_code, :Star_code1525 when /\A\// # /1526 yield :Slash_code, :Slash_code1527 when /\A\^/ # ^1528 yield :Caret_code, :Caret_code1529 when /\A\.\.\./ # ...1530 yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE1531 when /\A\.\./ # ..1532 yield :SYM_ELLIPSIS, :SYM_ELLIPSIS1533 when /\A\./ # .1534 yield :Dot_code, :Dot_code1535 when /\A\;/ # ;1536 yield :Semicolon_code, :Semicolon_code1537 when /\A\,/ # ,1538 yield :Comma_code, :Comma_code1539 when /\A\:/ # :1540 yield :Colon_code, :Colon_code1541 when /\A\!/ # !1542 yield :Exclamation_code, :Exclamation_code1543 when /\A\(/ # (1544 yield :Left_parenthesis_code, :Left_parenthesis_code1545 when /\A\)/ # )1546 yield :Right_parenthesis_code, :Right_parenthesis_code1547 when /\A\{\// #V_REGEXP1548 if @adl_type.last != :regexp1549 @in_regexp = true1550 @adl_type.push(:regexp)1551 yield :START_REGEXP_BLOCK, :START_REGEXP_BLOCK1552 else1553 raise1554 end1555 # yield :V_REGEXP, :V_REGEXP1556 when /\A\{/ # {1557 @adl_type.push(:cadl)1558 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: entering cADL at #{@filename}:#{@lineno}")1559 yield :SYM_START_CBLOCK, :SYM_START_CBLOCK1560 when /\A\}/ # }1561 adl_type = @adl_type.pop1562 # puts "Escaping #{adl_type}"1563 assert_at(__FILE__,__LINE__){adl_type == :cadl}1564 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: exiting cADL at #{@filename}:#{@lineno}")1565 yield :SYM_END_CBLOCK, :SYM_END_CBLOCK1566 when /\A\$/ # $1567 yield :Dollar_code, :Dollar_code1568 when /\A\?\?/ # ??1569 yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN1570 when /\A\?/ # ?1571 yield :Question_mark_code, :Question_mark_code1572 when /\A\|/ # |1573 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")1574 if @in_interval1575 @in_interval = false1576 else1577 # @in_interval = false1578 @in_interval = true1579 end1580 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")1581 yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM1582 1583 when /\A\[[a-zA-Z0-9._\-]+::[a-zA-Z0-9._\-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]1584 yield :V_QUALIFIED_TERM_CODE_REF, $&1585 when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF1586 yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&1587 when /\A\[([a-zA-Z0-9()._\-]+::[a-zA-Z0-9._\_-]+)\]/1588 yield :V_TERM_CODE_CONSTRAINT, :V_TERM_CODE_CONSTRAINT1589 when /\A\[[a-zA-Z0-9\(\)\._\-]+::[ \t\n]*/1590 @adl_type.push(:term_constraint)1591 yield :START_TERM_CODE_CONSTRAINT, $&1592 when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF1593 yield :V_LOCAL_TERM_CODE_REF, $&1594 when /\A\[/ # [1595 yield :Left_bracket_code, :Left_bracket_code1596 when /\A\]/ # ]1597 yield :Right_bracket_code, :Right_bracket_code1598 when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER1599 yield :V_GENERIC_TYPE_IDENTIFIER, $&1600 when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X][T\t][hH?X][hH?X]:[mM?X][mM?X]:[sS?X][sS?X]/1601 yield :V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN, $&1602 when /\A[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X]/1603 yield :V_ISO8601_DATE_CONSTRAINT_PATTERN, $&1604 when /\A[hH][hH]:[mM?X][mM?X]:[sS?X][sS?X]/1605 yield :V_ISO8601_TIME_CONSTRAINT_PATTERN, $&1606 when /\A[a-z][a-zA-Z0-9_]*/1607 word = $&.dup1608 if @@cadl_reserved[word.downcase]1609 yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]1610 else1611 @@log.info("#{__FILE__}:#{__LINE__}: scan_cadl: V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}:#{@lineno}")1612 yield :V_ATTRIBUTE_IDENTIFIER, word #V_ATTRIBUTE_IDENTIFIER /\A[a-z][a-zA-Z0-9_]*/1613 end1614 when /\A[A-Z][a-zA-Z0-9_]*/1615 word = $&.dup1616 if @@cadl_reserved[word.downcase]1617 yield @@cadl_reserved[word.downcase], @@cadl_reserved[word.downcase]1618 else1619 yield :V_TYPE_IDENTIFIER, $&1620 end1621 when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE1622 yield :V_LOCAL_CODE, $&1623 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-1624 yield :V_ISO8601_EXTENDED_DATE_TIME, $&1625 when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]1626 yield :V_ISO8601_EXTENDED_TIME, $&1627 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD1628 yield :V_ISO8601_EXTENDED_DATE, $&1629 when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER1630 yield :V_INTEGER, $&1631 when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL1632 yield :V_REAL, $&1633 when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING1634 when /\A"([^"]*)"/m #V_STRING1635 yield :V_STRING, $11636 when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI1637 yield :V_URI, $&1638 ### when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS1639 ### yield :V_ISO8601_DURATION, $&1640 when /\A\S/ #UTF8CHAR1641 yield :UTF8CHAR, $&1642 else1643 raise1644 end1645 data = $' # variable $' receives the string after the match1646 when :adl1647 # puts "Entering scan_adl"1648 data = scan_adl(data) do |sym, val|1649 yield sym, val1650 end1651 when :dadl1652 # puts "Entering scan_dadl"1653 data = scan_dadl(data) do |sym, val|1654 yield sym, val1655 end1656 when :regexp1657 # puts "Entering scan_regexp"1658 data = scan_regexp(data) do |sym, val|1659 yield sym, val1660 end1661 when :term_constraint1662 # puts "Entering scan_term_constraint"1663 data = scan_term_constraint(data) do |sym, val|1664 yield sym, val1665 end1666 else1667 raise1668 end1669 end # of until1670 end # of scan_cadl1671 1672 def scan_dadl(data)1673 until data.nil? do1674 case @adl_type.last1675 when :dadl1676 # puts "Entering scan_dadl"1677 case scanned = @@dadl_scanner.parse(data)1678 when Yaparc::Result::OK1679 yield scanned.value1680 data = scanned.input1681 else1682 end1683 1684 case data1685 when /\A\n/ # carriage return1686 @lineno += 11687 ;1688 when /\A[ \t\r\f]+/ #just drop it1689 ;1690 when /\A--.*\n/ # single line comment1691 @lineno += 11692 @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: COMMENT = #{$&} at #{@filename}:#{@lineno}")1693 ;1694 ###----------/* symbols */ -------------------------------------------------1695 when /\A\=/ # =1696 yield :SYM_EQ, :SYM_EQ1697 when /\A\>\=/ # >=1698 yield :SYM_GE, :SYM_GE1699 when /\A\<\=/ # <=1700 yield :SYM_LE, :SYM_LE1701 when /\A\</ # <1702 if @in_interval1703 yield :SYM_LT, :SYM_LT1704 else1705 @adl_type.push(:dadl)1706 yield :SYM_START_DBLOCK, :SYM_START_DBLOCK1707 end1708 when /\A\>/ # >1709 if @in_interval1710 # @in_interval = false1711 yield :SYM_GT, :SYM_GT1712 elsif @in_c_domain_type == true1713 assert_at(__FILE__,__LINE__){@adl_type.last == :dadl}1714 adl_type = @adl_type.pop1715 if @adl_type.last == :cadl1716 @in_c_domain_type = false1717 yield :END_V_C_DOMAIN_TYPE_BLOCK, $&1718 else1719 yield :SYM_END_DBLOCK, $&1720 end1721 elsif @in_c_domain_type == false1722 adl_type = @adl_type.pop1723 # puts "Escaping #{adl_type}"1724 assert_at(__FILE__,__LINE__){adl_type == :dadl}1725 yield :SYM_END_DBLOCK, $&1726 else1727 raise1728 end1729 when /\A\-/ # -1730 yield :Minus_code, :Minus_code1731 when /\A\+/ # +1732 yield :Plus_code, :Plus_code1733 when /\A\*/ # *1734 yield :Star_code, :Star_code1735 when /\A\// # /1736 yield :Slash_code, :Slash_code1737 when /\A\^/ # ^1738 yield :Caret_code, :Caret_code1739 when /\A\.\.\./ # ...1740 yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE1741 when /\A\.\./ # ..1742 yield :SYM_ELLIPSIS, :SYM_ELLIPSIS1743 when /\A\./ # .1744 yield :Dot_code, :Dot_code1745 when /\A\;/ # ;1746 yield :Semicolon_code, :Semicolon_code1747 when /\A\,/ # ,1748 yield :Comma_code, :Comma_code1749 when /\A\:/ # :1750 yield :Colon_code, :Colon_code1751 when /\A\!/ # !1752 yield :Exclamation_code, :Exclamation_code1753 when /\A\(/ # (1754 yield :Left_parenthesis_code, :Left_parenthesis_code1755 when /\A\)/ # )1756 yield :Right_parenthesis_code, :Right_parenthesis_code1757 when /\A\$/ # $1758 yield :Dollar_code, :Dollar_code1759 when /\A\?\?/ # ??1760 yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN1761 when /\A\?/ # ?1762 yield :Question_mark_code, :Question_mark_code1763 when /\A\|/ # |1764 @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: @in_interval = #{@in_interval} at #{@filename}:#{@lineno}")1765 if @in_interval1766 @in_interval = false1767 else1768 # @in_interval = false1769 @in_interval = true1770 end1771 @@log.info("#{__FILE__}:#{__LINE__}: scan_dadl: SYM_INTERVAL_DELIM at #{@filename}:#{@lineno}")1772 yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM1773 ### when /\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]1774 ### yield :V_QUALIFIED_TERM_CODE_REF, $&1775 ### when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF1776 ### yield :V_LOCAL_TERM_CODE_REF, $&1777 ### when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF1778 ### yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&1779 when /\A\[/ # [1780 yield :Left_bracket_code, :Left_bracket_code1781 when /\A\]/ # ]1782 yield :Right_bracket_code, :Right_bracket_code1783 ### when /\A[A-Z][a-zA-Z0-9_-]*/1784 ### yield :V_TYPE_IDENTIFIER, $&1785 ### when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER1786 ### yield :V_GENERIC_TYPE_IDENTIFIER, $&1787 ### when /\A[a-z][a-zA-Z0-9_]*/1788 ### word = $&.downcase1789 ### if @@dadl_reserved[word]1790 ### yield @@dadl_reserved[word], @@dadl_reserved[word]1791 ### else1792 ### yield :V_ATTRIBUTE_IDENTIFIER, $&1793 ### end1794 ### when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE1795 ### yield :V_LOCAL_CODE, $&1796 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-1797 yield :V_ISO8601_EXTENDED_DATE_TIME, $&1798 when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]1799 yield :V_ISO8601_EXTENDED_TIME, $&1800 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD1801 yield :V_ISO8601_EXTENDED_DATE, $&1802 when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER1803 yield :V_GENERIC_TYPE_IDENTIFIER, $&1804 when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER1805 yield :V_INTEGER, $&1806 ### when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL1807 ### yield :V_REAL, $&1808 # when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING1809 ### when /\A"([^"]*)"/m #V_STRING1810 ### yield :V_STRING, $11811 when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI1812 yield :V_URI, $&1813 ### when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS1814 ### yield :V_ISO8601_DURATION, $&1815 when /\A\S/ #UTF8CHAR1816 yield :UTF8CHAR, $&1817 end1818 data = $' # variable $' receives the string after the match1819 when :adl1820 # puts "Entering scan_adl"1821 data = scan_adl(data) do |sym, val|1822 yield sym, val1823 end1824 when :cadl1825 # puts "Entering scan_cadl"1826 data = scan_cadl(data) do |sym, val|1827 yield sym, val1828 end1829 when :regexp1830 # puts "Entering scan_regexp"1831 data = scan_regexp(data) do |sym, val|1832 yield sym, val1833 end1834 when :term_constraint1835 # puts "Entering scan_term_constraint"1836 data = scan_term_constraint(data) do |sym, val|1837 yield sym, val1838 end1839 else1840 raise1841 end1842 end1843 end # of scan_dadl1844 1845 def scan_regexp(data)1846 until data.nil? do1847 case @adl_type.last1848 when :regexp1849 # puts "Entering scan_regexp"1850 case data1851 when /\A\/\}/ #V_REGEXP1852 if @adl_type.last == :regexp1853 @in_regexp = false1854 @adl_type.pop1855 yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK1856 else1857 raise1858 end1859 when /\A(.*)(\/\})/ #V_REGEXP1860 yield :REGEXP_BODY, $11861 if @adl_type.last == :regexp1862 @in_regexp = false1863 @adl_type.pop1864 yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK1865 else1866 raise1867 end1868 else1869 raise data1870 end1871 data = $' # variable $' receives the string after the match1872 when :adl1873 # puts "Entering scan_adl"1874 data = scan_adl(data) do |sym, val|1875 yield sym, val1876 end1877 when :dadl1878 # puts "Entering scan_dadl"1879 data = scan_dadl(data) do |sym, val|1880 yield sym, val1881 end1882 when :cadl1883 # puts "Entering scan_cadl"1884 data = scan_cadl(data) do |sym, val|1885 yield sym, val1886 end1887 when :term_constraint1888 # puts "Entering scan_term_constraint"1889 data = scan_term_constraint(data) do |sym, val|1890 yield sym, val1891 end1892 else1893 raise1894 end1895 end1896 end # of scan_regexp1897 1898 def scan_term_constraint(data)1899 until data.nil? do1900 case @adl_type.last1901 when :term_constraint1902 # puts "Entering scan_term_constraint"1903 case data1904 when /\A\n/ # carriage return1905 @lineno += 11906 ;1907 when /\A[ \t\r\f]+/ #just drop it1908 ;1909 when /\A--.*$/ # single line comment1910 @lineno += 11911 @@log.info("#{__FILE__}:#{__LINE__}: scan_term_constraint: COMMENT = #{$&} at #{@filename}:#{@lineno}")1912 ;1913 when /\A[a-zA-Z0-9\._\-]+[ \t]*,/ # match any line, with ',' termination1914 yield :TERM_CODE, $&1915 when /\A[a-zA-Z0-9\._\-]+[ \t]*;/ #match second last line with ';' termination (assumed value)1916 yield :TERM_CODE, $&1917 # when /\A[a-zA-Z0-9\._\-]+[ \t]*\]/ # match final line, terminating in ']'1918 when /\A[a-zA-Z0-9\._\-]*[ \t]*\]/ # match final line, terminating in ']'1919 adl_type = @adl_type.pop1920 assert_at(__FILE__,__LINE__){adl_type == :term_constraint}1921 yield :END_TERM_CODE_CONSTRAINT, $&1922 else1923 raise "data = #{data}"1924 end1925 data = $' # variable $' receives the string after the match1926 when :adl1927 # puts "Entering scan_adl"1928 data = scan_adl(data) do |sym, val|1929 yield sym, val1930 end1931 when :dadl1932 # puts "Entering scan_dadl"1933 data = scan_dadl(data) do |sym, val|1934 yield sym, val1935 end1936 when :cadl1937 # puts "Entering scan_cadl"1938 data = scan_cadl(data) do |sym, val|1939 yield sym, val1940 end1941 else1942 raise1943 end1944 end1945 end # of scan_term_constraint1946 1296 1947 1297 … … 1964 1314 1965 1315 1966 1316 __END__ 1967 1317 1968 1318 -
ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl
r116 r290 10 10 ["name"] = <"Thomas Beale"> 11 11 ["organisation"] = <"Ocean Informatics"> 12 ["date"] = <" 2005-10-10">12 ["date"] = <"10/10/2005"> 13 13 > 14 14 details = < -
ruby/branches/0.5/lib/adl_parser/test/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl
r116 r290 25 25 ["name"] = <"Sam Heard"> 26 26 ["organisation"] = <"Ocean Informatics"> 27 ["date"] = <" 2004-05-18">27 ["date"] = <"18/05/2004"> 28 28 ["email"] = <"sam.heard@oceaninformatics.biz"> 29 29 > … … 45 45 ["de"] = < 46 46 language = <[ISO_639-1::de]> 47 purpose = <"Zur Dokumentation des Apgar Wertes oder Beurteilung f%G �%@r Neugeborene. Der zu Grunde liegende Zeitpunkt der Ereignisreihe ist immer die Geburt.">48 use = <"Erm%G �%@glicht die Dokumentation des Wohlergehens des S%G�%@uglings 1, 2, 5 und/ oder 10 Minuten nach der Geburt. Die Summe kann einzeln dokumentiert werden - falls nur diese verf%G�%@gbar ist - es sollten aber alle f%G�%@nf Zahlenwerte vervollst%G�%@ndigt werden, damit die Summe errechnet werden kann. Die Gesamtsumme ist die Summe der f%G�%@nf Zahlenwerte (minimal 0, maximal 10).">47 purpose = <"Zur Dokumentation des Apgar Wertes oder Beurteilung f%G�%@r Neugeborene. Der zu Grunde liegende Zeitpunkt der Ereignisreihe ist immer die Geburt."> 48 use = <"Erm%G�%@glicht die Dokumentation des Wohlergehens des S%G�%@uglings 1, 2, 5 und/ oder 10 Minuten nach der Geburt. Die Summe kann einzeln dokumentiert werden - falls nur diese verf%G�%@gbar ist - es sollten aber alle f%G�%@nf Zahlenwerte vervollst%G�%@ndigt werden, damit die Summe errechnet werden kann. Die Gesamtsumme ist die Summe der f%G�%@nf Zahlenwerte (minimal 0, maximal 10)."> 49 49 keywords = <"Apgar", "Neugeborenes", "Index", "Wert"> 50 misuse = <"Nur teilweise Vervollst%G �%@ndigung der Werte und Addieren von weniger als f%G�%@nf Werten zur Gesamtsumme.">50 misuse = <"Nur teilweise Vervollst%G�%@ndigung der Werte und Addieren von weniger als f%G�%@nf Werten zur Gesamtsumme."> 51 51 > 52 52 > … … 414 414 items = < 415 415 ["at0000"] = < 416 description = <"Klinischer Wert, abgeleitet von der Beurteilung der Atmung, der Hautfarbe, dem Muskeltonus, der Herzfrequenz und der Reaktion von Reflexen, %G �%@blicherweise 1, 5 und 10 Minuten nach der Geburt erhoben">416 description = <"Klinischer Wert, abgeleitet von der Beurteilung der Atmung, der Hautfarbe, dem Muskeltonus, der Herzfrequenz und der Reaktion von Reflexen, %G�%@blicherweise 1, 5 und 10 Minuten nach der Geburt erhoben"> 417 417 text = <"Apgar Wert"> 418 418 > … … 438 438 > 439 439 ["at0007"] = < 440 description = <"Herzfrequenz von weniger als 100 Schl%G �%@gen pro Minute">441 text = <"Weniger als 100 Schl%G �%@ge pro Minute">440 description = <"Herzfrequenz von weniger als 100 Schl%G�%@gen pro Minute"> 441 text = <"Weniger als 100 Schl%G�%@ge pro Minute"> 442 442 > 443 443 ["at0008"] = < 444 description = <"Herzfrequenz von mehr als oder genau 100 Schl%G �%@gen pro Minute">445 text = <"Mehr als oder genau 100 Schl%G �%@ge pro Minute">444 description = <"Herzfrequenz von mehr als oder genau 100 Schl%G�%@gen pro Minute"> 445 text = <"Mehr als oder genau 100 Schl%G�%@ge pro Minute"> 446 446 > 447 447 ["at0009"] = < … … 478 478 > 479 479 ["at0017"] = < 480 description = <"Beurteilung der Reaktion des Neugeborenen auf die Absaugung der Nasenl%G �%@cher">480 description = <"Beurteilung der Reaktion des Neugeborenen auf die Absaugung der Nasenl%G�%@cher"> 481 481 text = <"Reflexantwort"> 482 482 > 483 483 ["at0018"] = < 484 description = <"kein W%G �%@rgen oder keine Reaktion auf das Absaugen der Atemwege">484 description = <"kein W%G�%@rgen oder keine Reaktion auf das Absaugen der Atemwege"> 485 485 text = <"Keine Reaktion auf die Absaugung der Atemwege"> 486 486 > 487 487 ["at0019"] = < 488 488 description = <"Grimasse als einzige Reaktion auf das Absaugen der Atemwege"> 489 text = <"Grimasse w%G �%@hrend der Absaugung der Atemwege">489 text = <"Grimasse w%G�%@hrend der Absaugung der Atemwege"> 490 490 > 491 491 ["at0020"] = < 492 description = <"Grimasse und husten, niesen oder w%G �%@rgen als Reaktion auf die Absaugung der Atemwege">493 text = <"Grimasse und Husten/Niesen w%G �%@hrend der Absaugung der Atemwege ">492 description = <"Grimasse und husten, niesen oder w%G�%@rgen als Reaktion auf die Absaugung der Atemwege"> 493 text = <"Grimasse und Husten/Niesen w%G�%@hrend der Absaugung der Atemwege "> 494 494 > 495 495 ["at0021"] = < 496 description = <"Die Farbe der Haut am K%G �%@rper, am Rumpf und an den Gliedern">496 description = <"Die Farbe der Haut am K%G�%@rper, am Rumpf und an den Gliedern"> 497 497 text = <"Hautfarbe"> 498 498 > 499 499 ["at0022"] = < 500 description = <"Der K%G �%@rper ist blass oder blau gef%G�%@rbt">501 text = <"Gesamter K%G �%@rper ist blau oder blass">500 description = <"Der K%G�%@rper ist blass oder blau gef%G�%@rbt"> 501 text = <"Gesamter K%G�%@rper ist blau oder blass"> 502 502 > 503 503 ["at0023"] = < 504 description = <"Der K%G �%@rper ist rosig, H%G�%@nde und F%G��%@e sind blass oder blau">505 text = <"Gesunde K%G �%@rperfarbe, blaue H%G�%@nde oder F%G��%@e">504 description = <"Der K%G�%@rper ist rosig, H%G�%@nde und F%G��%@e sind blass oder blau"> 505 text = <"Gesunde K%G�%@rperfarbe, blaue H%G�%@nde oder F%G��%@e"> 506 506 > 507 507 ["at0024"] = < 508 description = <"Rosige oder gesunde F%G �%@rbung des gesamten K%G�%@rpers">509 text = <"Vollst%G �%@ndig gesunde oder rosige Farbe">508 description = <"Rosige oder gesunde F%G�%@rbung des gesamten K%G�%@rpers"> 509 text = <"Vollst%G�%@ndig gesunde oder rosige Farbe"> 510 510 > 511 511 ["at0025"] = < -
ruby/branches/0.5/lib/adl_parser/test/parser_test.rb
r167 r290 1 #require 'lib/parser.rb' 2 require 'lib/adl_parser.rb' 3 require 'test/unit' 1 require File.dirname(__FILE__) + '/test_helper.rb' 4 2 5 3 class ADLParserTest < Test::Unit::TestCase … … 8 6 end 9 7 10 def test_init8 must "assert parser instance" do 11 9 assert_instance_of ::OpenEHR::ADL::Parser,@parser 12 10 end 13 11 14 def test_parse 15 laboratory_request = File.read('test/adl/openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl') 16 assert_nothing_raised do 17 result = @parser.parse(laboratory_request, 'openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl') 18 assert_instance_of OpenEhr::AM::Archetype::ARCHETYPE, result 19 assert_instance_of OpenEhr::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, result.description 20 assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, result.definition 21 # assert_equal '', result.definition 22 end 23 24 apgar = File.read('test/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl') 25 assert_nothing_raised do 26 result = @parser.parse(apgar, 'openEHR-EHR-OBSERVATION.apgar.v1.adl') 27 assert_instance_of OpenEhr::AM::Archetype::ARCHETYPE, result 28 assert_instance_of OpenEhr::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, result.description 29 assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, result.definition 30 end 31 32 evaluation = File.read('test/adl/openEHR-EHR-EVALUATION.adverse.v1.adl') 33 assert_nothing_raised do 34 @parser.parse(evaluation, 'openEHR-EHR-EVALUATION.adverse.v1.adl') 35 end 36 37 38 39 referral = File.read('test/adl/openEHR-EHR-ITEM_TREE.referral.v1.adl') 40 assert_nothing_raised do 41 @parser.parse(referral, 'openEHR-EHR-ITEM_TREE.referral.v1.adl') 42 end 43 44 exam_fetus = File.read('test/adl/openEHR-EHR-CLUSTER.exam-fetus.v1.adl') 45 assert_nothing_raised do 46 @parser.parse(exam_fetus, 'openEHR-EHR-CLUSTER.exam-fetus.v1.adl') 47 end 48 49 exam_uterine_cervix = File.read('test/adl/openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl') 50 assert_nothing_raised do 51 @parser.parse(exam_uterine_cervix, 'openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl') 52 end 53 54 imaging = File.read('test/adl/openEHR-EHR-ACTION.imaging.v1.adl') 55 assert_nothing_raised do 56 @parser.parse(imaging, 'openEHR-EHR-ACTION.imaging.v1.adl') 57 end 58 59 exam_nervous_system = File.read('test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl') 60 assert_nothing_raised do 61 @parser.parse(exam_nervous_system, 'openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl') 62 end 63 exam_generic = File.read('test/adl/openEHR-EHR-CLUSTER.exam-generic.v1.adl') 64 assert_nothing_raised do 65 @parser.parse(exam_generic, 'openEHR-EHR-CLUSTER.exam-generic.v1.adl') 66 end 67 exam_generic_mass = File.read('test/adl/openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl') 68 assert_nothing_raised do 69 @parser.parse(exam_generic_mass, 'openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl') 70 end 71 exam_generic_lymphnode = File.read('test/adl/openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl') 72 assert_nothing_raised do 73 @parser.parse(exam_generic_lymphnode, 'openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl') 74 end 75 exam_generic_joint = File.read('test/adl/openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl') 76 assert_nothing_raised do 77 @parser.parse(exam_generic_joint, 'openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl') 78 end 79 exam_chest = File.read('test/adl/openEHR-EHR-CLUSTER.exam-chest.v1.adl') 80 assert_nothing_raised do 81 @parser.parse(exam_chest, 'openEHR-EHR-CLUSTER.exam-chest.v1.adl') 82 end 83 exam_abdomen = File.read('test/adl/openEHR-EHR-CLUSTER.exam-abdomen.v1.adl') 84 assert_nothing_raised do 85 @parser.parse(exam_abdomen, 'openEHR-EHR-CLUSTER.exam-abdomen.v1.adl') 86 end 87 cluster_auscultation = File.read('test/adl/openEHR-EHR-CLUSTER.auscultation.v1.adl') 88 assert_nothing_raised do 89 @parser.parse(cluster_auscultation, 'openEHR-EHR-CLUSTER.auscultation.v1.adl') 90 end 91 cluster_auscultation_chest = File.read('test/adl/openEHR-EHR-CLUSTER.auscultation-chest.v1.adl') 92 assert_nothing_raised do 93 @parser.parse(cluster_auscultation_chest, 'openEHR-EHR-CLUSTER.auscultation-chest.v1.adl') 94 end 95 vital_signs = File.read('test/adl/openEHR-EHR-SECTION.vital_signs.v1.adl') 96 assert_nothing_raised do 97 @parser.parse(vital_signs, 'openEHR-EHR-SECTION.vital_signs.v1') 98 end 99 summary = File.read('test/adl/openEHR-EHR-SECTION.summary.v1.adl') 100 assert_nothing_raised do 101 @parser.parse(summary, 'openEHR-EHR-SECTION.summary.v1.adl') 102 end 103 104 findings = File.read('test/adl/openEHR-EHR-SECTION.findings.v1.adl') 105 assert_nothing_raised do 106 @parser.parse(findings, 'openEHR-EHR-SECTION.findings.v1.adl') 107 end 108 109 reason_for_encounter = File.read('test/adl/openEHR-EHR-SECTION.reason_for_encounter.v1.adl') 110 assert_nothing_raised do 111 @parser.parse(reason_for_encounter, 'openEHR-EHR-SECTION.reason_for_encounter.v1.adl') 112 end 113 114 imaging = File.read('test/adl/openEHR-EHR-ITEM_TREE.imaging.v1.adl') 115 assert_nothing_raised do 116 @parser.parse(imaging, 'openEHR-EHR-ITEM_TREE.imaging.v1.adl') 117 end 118 instruction_referral = File.read('test/adl/openEHR-EHR-INSTRUCTION.referral.v1.adl') 119 assert_nothing_raised do 120 @parser.parse(instruction_referral, 'openEHR-EHR-INSTRUCTION.referral.v1.adl') 121 end 122 instruction_medication = File.read('test/adl/openEHR-EHR-INSTRUCTION.medication.v1.adl') 123 assert_nothing_raised do 124 @parser.parse(instruction_medication, 'openEHR-EHR-INSTRUCTION.medication.v1.adl') 125 end 126 action_referral = File.read('test/adl/openEHR-EHR-ACTION.referral.v1.adl') 127 assert_nothing_raised do 128 @parser.parse(action_referral, 'openEHR-EHR-ACTION.referral.v1.adl') 129 end 130 131 dimensions_circumference = File.read('test/adl/openEHR-EHR-CLUSTER.dimensions.v1.adl') 132 assert_nothing_raised do 133 @parser.parse(dimensions_circumference, 'openEHR-EHR-CLUSTER.dimensions.v1.adl') 134 end 135 136 discharge = File.read('test/adl/openEHR-EHR-COMPOSITION.discharge.v1draft.adl') 137 assert_nothing_raised do 138 @parser.parse(discharge, 'openEHR-EHR-COMPOSITION.discharge.v1draft.adl') 139 end 140 141 encounter = File.read('test/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl') 142 assert_nothing_raised do 143 @parser.parse(encounter, 'openEHR-EHR-COMPOSITION.encounter.v1draft.adl') 144 end 145 146 147 # medication = File.read('test/adl/openEHR-EHR-ITEM_TREE.medication.v1.adl') 148 # assert_nothing_raised do 149 # @parser.parse(medication, 'openEHR-EHR-ITEM_TREE.medication.v1.adl') 150 # end 151 end 12 must "test_archetype_id.adl be properly parsed" do 13 file = File.read("#{TEST_ROOT_DIR}/adl/test_archetype_id.adl") 14 assert_nothing_raised do 15 ast = @parser.parse(file, 'openEHR-EHR-SECTION.summary.v1') 16 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 17 end 18 end 19 20 must "openEHR-EHR-ACTION.imaging.v1.adl be properly parsed" do 21 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ACTION.imaging.v1.adl") 22 assert_nothing_raised do 23 ast = @parser.parse(file, 'openEHR-EHR-ACTION.imaging.v1') 24 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 25 end 26 end 27 28 must "openEHR-EHR-ACTION.referral.v1.adl be properly parsed" do 29 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ACTION.referral.v1.adl") 30 assert_nothing_raised do 31 ast = @parser.parse(file, 'openEHR-EHR-ACTION.referral.v1') 32 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 33 end 34 end 35 36 must "openEHR-EHR-CLUSTER.auscultation-chest.v1.adl be properly parsed" do 37 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.auscultation-chest.v1.adl") 38 assert_nothing_raised do 39 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.auscultation-chest.v1') 40 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 41 end 42 end 43 44 must "openEHR-EHR-CLUSTER.auscultation.v1.adl be properly parsed" do 45 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.auscultation.v1.adl") 46 assert_nothing_raised do 47 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.auscultation.v1') 48 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 49 end 50 end 51 52 53 must "openEHR-EHR-CLUSTER.exam-abdomen.v1.adl be properly parsed" do 54 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-abdomen.v1.adl") 55 assert_nothing_raised do 56 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-abdomen.v1') 57 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 58 end 59 end 60 61 must "openEHR-EHR-CLUSTER.exam-chest.v1.adl be properly parsed" do 62 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-chest.v1.adl") 63 assert_nothing_raised do 64 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-chest.v1') 65 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 66 end 67 end 68 69 must "openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl be properly parsed" do 70 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl") 71 assert_nothing_raised do 72 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-generic-joint.v1') 73 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 74 end 75 end 76 77 must "openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl be properly parsed" do 78 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl") 79 assert_nothing_raised do 80 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1') 81 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 82 end 83 end 84 85 must "openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl be properly parsed" do 86 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl") 87 assert_nothing_raised do 88 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-generic-mass.v1') 89 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 90 end 91 end 92 93 must "openEHR-EHR-CLUSTER.exam-generic.v1.adl be properly parsed" do 94 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-generic.v1.adl") 95 assert_nothing_raised do 96 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-generic.v1') 97 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 98 end 99 end 100 101 must "openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl be properly parsed" do 102 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl") 103 assert_nothing_raised do 104 ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-nervous_system.v1') 105 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 106 end 107 end 108 109 must "openEHR-EHR-COMPOSITION.discharge.v1draft.adl be properly parsed" do 110 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-COMPOSITION.discharge.v1draft.adl") 111 assert_nothing_raised do 112 ast = @parser.parse(file, 'openEHR-EHR-COMPOSITION.discharge.v1draft') 113 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 114 end 115 end 116 117 must "openEHR-EHR-COMPOSITION.encounter.v1draft.adl be properly parsed" do 118 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl") 119 assert_nothing_raised do 120 ast = @parser.parse(file, 'openEHR-EHR-COMPOSITION.encounter.v1draft') 121 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 122 end 123 end 124 125 must "openEHR-EHR-INSTRUCTION.medication.v1.adl be properly parsed" do 126 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-INSTRUCTION.medication.v1.adl") 127 assert_nothing_raised do 128 ast = @parser.parse(file, 'openEHR-EHR-INSTRUCTION.medication.v1') 129 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 130 end 131 end 132 133 must "openEHR-EHR-INSTRUCTION.referral.v1.adl be properly parsed" do 134 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-INSTRUCTION.referral.v1.adl") 135 assert_nothing_raised do 136 ast = @parser.parse(file, 'openEHR-EHR-INSTRUCTION.referral.v1') 137 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 138 end 139 end 140 141 must "openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl be properly parsed" do 142 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl") 143 assert_nothing_raised do 144 ast = @parser.parse(file, 'openEHR-EHR-ITEM_TREE.Laboratory_request.v1') 145 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 146 end 147 end 148 149 150 must "openEHR-EHR-OBSERVATION.apgar.v1.adl be properly parsed" do 151 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl") 152 assert_nothing_raised do 153 ast = @parser.parse(file, 'openEHR-EHR-OBSERVATION.apgar.v1') 154 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 155 end 156 end 157 158 must "openEHR-EHR-SECTION.findings.v1.adl be properly parsed" do 159 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.findings.v1.adl") 160 assert_nothing_raised do 161 ast = @parser.parse(file, 'openEHR-EHR-SECTION.findings.v1') 162 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 163 end 164 end 165 166 must "openEHR-EHR-SECTION.reason_for_encounter.v1.adl be properly parsed" do 167 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.reason_for_encounter.v1.adl") 168 assert_nothing_raised do 169 ast = @parser.parse(file, 'openEHR-EHR-SECTION.reason_for_encounter.v1') 170 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 171 end 172 end 173 174 175 must "openEHR-EHR-SECTION.vital_signs.v1.adl be properly parsed" do 176 file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-SECTION.vital_signs.v1.adl") 177 assert_nothing_raised do 178 ast = @parser.parse(file, 'openEHR-EHR-SECTION.vital_signs.v1') 179 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 180 end 181 end 182 183 184 # C_DV_QUANTITY parse error 185 # must "openEHR-EHR-CLUSTER.dimensions-circumference.v1.adl be properly parsed" do 186 # file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.dimensions-circumference.v1.adl") 187 # assert_nothing_raised do 188 # ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.dimensions-circumference.v1') 189 # assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 190 # end 191 # end 192 193 # must "openEHR-EHR-CLUSTER.dimensions.v1.adl be properly parsed" do 194 # file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.dimensions.v1.adl") 195 # assert_nothing_raised do 196 # ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.dimensions.v1') 197 # assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 198 # end 199 # end 200 201 # must "openEHR-EHR-CLUSTER.exam-fetus.v1.adl be properly parsed" do 202 # file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-fetus.v1.adl") 203 # assert_nothing_raised do 204 # ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-fetus.v1') 205 # assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 206 # end 207 # end 208 209 # must "openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl be properly parsed" do 210 # file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl") 211 # assert_nothing_raised do 212 # ast = @parser.parse(file, 'openEHR-EHR-CLUSTER.exam-uterine_cervix.v1') 213 # assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 214 # end 215 # end 216 217 # must "openEHR-EHR-EVALUATION.adverse.v1.adl be properly parsed" do 218 # file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-EVALUATION.adverse.v1.adl") 219 # assert_nothing_raised do 220 # ast = @parser.parse(file, 'openEHR-EHR-EVALUATION.adverse.v1') 221 # assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 222 # end 223 # end 224 # must "openEHR-EHR-OBSERVATION.body_mass_index.v1.adl be properly parsed" do 225 # file = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl") 226 # assert_nothing_raised do 227 # ast = @parser.parse(file, 'openEHR-EHR-OBSERVATION.body_mass_index.v1') 228 # assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, ast.archetype_id 229 # end 230 # end 231 232 152 233 end -
ruby/branches/0.5/lib/adl_parser/test/scanner_test.rb
r167 r290 1 require 'lib/adl_parser.rb' 2 #require 'lib/scanner.rb' 3 require 'test/unit' 1 require File.dirname(__FILE__) + '/test_helper.rb' 4 2 5 class YaparcParserTest < Test::Unit::TestCase 6 def test_RootScanner 7 parser = OpenEhr::ADL::Scanner::DADL::RootScanner.new 8 assert_instance_of OpenEhr::ADL::Scanner::DADL::RootScanner,parser 9 result = parser.parse('') 3 class ADLScannerTest < Test::Unit::TestCase 4 def setup 5 @scanner = OpenEHR::ADL::Scanner::ADLScanner.new([:adl], "filename") 10 6 end 11 7 12 def test_V_LOCAL_TERM_CODE_REF 13 parser = OpenEhr::ADL::Scanner::Common::V_LOCAL_TERM_CODE_REF.new 14 assert_instance_of OpenEhr::ADL::Scanner::Common::V_LOCAL_TERM_CODE_REF,parser 15 result = parser.parse('[en-us]') 16 assert_instance_of Yaparc::Result::OK, result 8 must "assert OpenEHR::ADL::Scanner::ADLScanner scanner instance" do 9 assert_instance_of OpenEHR::ADL::Scanner::ADLScanner, @scanner 17 10 end 18 11 19 def test_V_QUALIFIED_TERM_CODE_REF 20 parser = OpenEhr::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF.new 21 assert_instance_of OpenEhr::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF,parser 22 result = parser.parse('[ISO_639::en]') 23 assert_instance_of Yaparc::Result::OK, result 24 result = parser.parse('[ISO_639::en-us]') 25 assert_instance_of Yaparc::Result::OK, result 12 must "assert ADLScanner scanner scan CR and lineno incremented" do 13 lineno = @scanner.lineno 14 @scanner.scan("\n") 15 assert_equal lineno+1, @scanner.lineno 26 16 end 27 17 28 def test_V_STRING 29 parser = OpenEhr::ADL::Scanner::Common::V_STRING.new 30 assert_instance_of OpenEhr::ADL::Scanner::Common::V_STRING,parser 31 result = parser.parse('"this is a string"') 32 assert_instance_of Yaparc::Result::OK, result 33 result = parser.parse('"en-us"') 34 assert_instance_of Yaparc::Result::OK, result 18 must "assert ADLScanner scanner scan ARCHETYPE_ID" do 19 lineno = @scanner.lineno 20 @scanner.scan("openEHR-EHR-OBSERVATION.body_mass_index.v1") do |sym, val| 21 assert_equal :V_ARCHETYPE_ID,sym 22 assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID,val 23 end 35 24 end 36 25 37 def test_V_REAL 38 parser = OpenEhr::ADL::Scanner::Common::V_REAL.new 39 assert_instance_of OpenEhr::ADL::Scanner::Common::V_REAL,parser 40 result = parser.parse('0.1') 41 assert_instance_of Yaparc::Result::OK, result 42 result = parser.parse('0.0..20000.0') 43 assert_instance_of Yaparc::Result::OK, result 44 assert_equal [:V_REAL, "0.0"], result.value 45 assert_equal "..20000.0", result.input 26 must "assert ADLScanner scanner scan white space and lineno unchanged" do 27 lineno = @scanner.lineno 28 @scanner.scan(" ") 29 assert_equal lineno, @scanner.lineno 46 30 end 47 31 48 def test_V_ISO8601_DURATION 49 parser = OpenEhr::ADL::Scanner::Common::V_ISO8601_DURATION.new 50 assert_instance_of OpenEhr::ADL::Scanner::Common::V_ISO8601_DURATION,parser 51 result = parser.parse('PT1M') 52 assert_instance_of Yaparc::Result::OK, result 53 result = parser.parse('PYMWDTHMS') 54 assert_instance_of Yaparc::Result::OK, result 55 assert_equal [:V_ISO8601_DURATION, "PYMWDTHMS"], result.value 32 must "assert ADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do 33 @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val| 34 assert_equal :V_QUALIFIED_TERM_CODE_REF,sym 35 assert_equal "ICD10AM(1998)::F23",val 36 end 37 end 38 end 39 40 class CADLScannerTest < Test::Unit::TestCase 41 def setup 42 @scanner = OpenEHR::ADL::Scanner::CADLScanner.new([:cadl], "filename") 56 43 end 57 44 58 def test_V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN 59 parser = OpenEhr::ADL::Scanner::CADL::V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN.new 60 assert_instance_of OpenEhr::ADL::Scanner::CADL::V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN,parser 61 result = parser.parse('yyyy-??-??T??:??:??') 62 assert_instance_of Yaparc::Result::OK, result 45 must "assert OpenEHR::ADL::Scanner::CADLScanner scanner instance" do 46 assert_instance_of OpenEHR::ADL::Scanner::CADLScanner, @scanner 63 47 end 64 48 65 def test_V_ISO8601_DATE_CONSTRAINT_PATTERN 66 parser = OpenEhr::ADL::Scanner::CADL::V_ISO8601_DATE_CONSTRAINT_PATTERN.new 67 assert_instance_of OpenEhr::ADL::Scanner::CADL::V_ISO8601_DATE_CONSTRAINT_PATTERN,parser 68 result = parser.parse('yyyy-mm-XX-dd') 69 assert_instance_of Yaparc::Result::OK, result 49 must "assert CADLScanner scanner scan V_ATTRIBUTE_IDENTIFIER" do 50 lineno = @scanner.lineno 51 @scanner.scan("identifier") do |sym, val| 52 assert_equal :V_ATTRIBUTE_IDENTIFIER, sym 53 assert_equal "identifier", val 54 end 55 assert_equal lineno, @scanner.lineno 70 56 end 71 57 72 def test_V_ISO8601_TIME_CONSTRAINT_PATTERN73 parser = OpenEhr::ADL::Scanner::CADL::V_ISO8601_TIME_CONSTRAINT_PATTERN.new74 assert_instance_of OpenEhr::ADL::Scanner::CADL::V_ISO8601_TIME_CONSTRAINT_PATTERN,parser75 result = parser.parse('hh:mm:ss:??')76 assert_instance_of Yaparc::Result::OK, result58 must "assert CADLScanner scanner scan reserved words" do 59 lineno = @scanner.lineno 60 @scanner.scan("then") do |sym, val| 61 assert_equal :SYM_THEN, sym 62 end 77 63 end 78 64 79 def test_dadl_reserved 80 parser = OpenEhr::ADL::Scanner::DADL::RootScanner.new 81 result = parser.parse('then') 82 assert_instance_of Yaparc::Result::OK, result 83 result = parser.parse('infinity') 84 assert_instance_of Yaparc::Result::OK, result 85 assert_equal [:SYM_INFINITY, :SYM_INFINITY], result.value 65 must "assert CADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do 66 @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val| 67 assert_equal :V_QUALIFIED_TERM_CODE_REF,sym 68 assert_equal "ICD10AM(1998)::F23",val 69 end 86 70 end 87 71 88 def test_cadl 89 parser = OpenEhr::ADL::Scanner::CADL::RootScanner.new 90 assert_instance_of OpenEhr::ADL::Scanner::CADL::RootScanner,parser 91 result = parser.parse('PT1M') 92 assert_instance_of Yaparc::Result::OK, result 93 assert_equal [:V_ISO8601_DURATION, "PT1M"], result.value 94 result = parser.parse('PYMWDTHMS') 95 assert_instance_of Yaparc::Result::OK, result 96 assert_equal [:V_ISO8601_DURATION, "PYMWDTHMS"], result.value 72 must "assert CADLScanner scanner scan V_ISO8601_DURATION" do 73 @scanner.scan("PT1M") do |sym, val| 74 assert_equal :V_ISO8601_DURATION,sym 75 assert_equal "PT1M",val 76 end 77 end 78 end 79 80 class DADLScannerTest < Test::Unit::TestCase 81 def setup 82 @scanner = OpenEHR::ADL::Scanner::DADLScanner.new([:dadl], "filename") 97 83 end 98 84 99 def test_cadl_reserved 100 parser = OpenEhr::ADL::Scanner::CADL::RootScanner.new 101 result = parser.parse('then') 102 assert_instance_of Yaparc::Result::OK, result 103 result = parser.parse('cardinality') 104 assert_instance_of Yaparc::Result::OK, result 105 assert_equal [:SYM_CARDINALITY, :SYM_CARDINALITY], result.value 106 result = parser.parse('ordered') 107 assert_instance_of Yaparc::Result::OK, result 108 assert_equal "", result.input 109 assert_equal [:SYM_ORDERED, :SYM_ORDERED], result.value 85 must "assert DADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do 86 @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val| 87 assert_equal :V_QUALIFIED_TERM_CODE_REF,sym 88 assert_equal "ICD10AM(1998)::F23",val 89 end 110 90 end 111 91 112 92 must "assert DADLScanner scanner scan V_ISO8601_EXTENDED_DATE" do 93 @scanner.scan("2005-10-10") do |sym, val| 94 assert_equal :V_ISO8601_EXTENDED_DATE,sym 95 assert_equal "2005-10-10",val 96 end 97 end 98 99 must "assert DADLScanner scanner scan V_STRING" do 100 @scanner.scan("\"string\"") do |sym, val| 101 assert_equal :V_STRING,sym 102 assert_equal "string",val 103 end 104 end 113 105 end -
ruby/branches/0.5/lib/adl_parser/test/semantic_test.rb
r116 r290 1 require 'lib/adl_parser.rb' 2 require 'test/unit' 1 require File.dirname(__FILE__) + '/test_helper.rb' 3 2 4 3 class ADLSemanticTest < Test::Unit::TestCase … … 7 6 end 8 7 9 def test_init8 must "assert adl parser instance" do 10 9 assert_instance_of ::OpenEHR::ADL::Parser,@parser 11 10 end -
ruby/branches/0.5/lib/adl_parser/test/shell_test.rb
r116 r290 1 require 'lib/adl_parser.rb' 2 require 'test/unit' 1 require File.dirname(__FILE__) + '/test_helper.rb' 3 2 4 3 class ShellADLValidatorTest < Test::Unit::TestCase … … 7 6 end 8 7 9 def test_init8 must "assert application validator instance" do 10 9 assert_instance_of ::OpenEHR::Application::ADLValidator,@adl_validator 11 10 end 12 11 13 def test_run 12 13 must "validating openEHR-EHR-CLUSTER.exam-nervous_system.v1 using File.open not raised" do 14 14 assert_nothing_raised do 15 adl_file = File.open( 'test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')15 adl_file = File.open("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl") 16 16 @adl_validator.run(adl_file) 17 17 end 18 end 19 20 must "validating openEHR-EHR-CLUSTER.exam-nervous_system.v1 using File.read not raised" do 18 21 assert_nothing_raised do 19 adl_string = File.open('test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl') 20 @adl_validator.run(adl_string) 21 end 22 assert_nothing_raised do 23 adl_string = File.read('test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl') 22 adl_string = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl") 24 23 stringio = StringIO.new(adl_string) 25 24 @adl_validator.run(stringio) -
ruby/branches/0.5/lib/adl_parser/test/validator_test.rb
r116 r290 1 require 'lib/adl_parser.rb'2 require 'test/unit' 1 require File.dirname(__FILE__) + '/test_helper.rb' 2 3 3 4 4 class ADLValidatorTest < Test::Unit::TestCase … … 7 7 end 8 8 9 def test_init9 must "assert adl validator instance" do 10 10 assert_instance_of ::OpenEHR::ADL::Validator,@validator 11 11 end 12 12 13 def test_validate14 exam_nervous_system = File.read( 'test/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl')13 must "assert validation openEHR-EHR-CLUSTER.exam-nervous_system.v1" do 14 exam_nervous_system = File.read("#{TEST_ROOT_DIR}/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl") 15 15 assert_nothing_raised do 16 @validator.validate(exam_nervous_system, 'openEHR-EHR-CLUSTER.exam-nervous_system.v1 .adl')16 @validator.validate(exam_nervous_system, 'openEHR-EHR-CLUSTER.exam-nervous_system.v1') 17 17 end 18 18 end 19 19 # exam_uterine_cervix = File.read('tests/openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl') 20 20 # # assert_raise(Racc::ParseError) do 21 21 # @validator.validate(exam_uterine_cervix, 'openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl') 22 22 # # end 23 24 end25 23 end -
ruby/branches/0.5/lib/models/Rakefile
r142 r290 41 41 s.email = 'openehr-jp@openehr.jp' 42 42 s.test_files = FileList['tests/test_*.rb', '*.adl'] 43 43 44 candidates = Dir.glob("{am,rm,docs,tests}/**/*") + FileList['COPYING', 'Rakefile','am.rb','assumed_library_types.rb','rm.rb'] 44 45 s.files = candidates.delete_if do |item|
Note:
See TracChangeset
for help on using the changeset viewer.