Changeset 324
- Timestamp:
- Oct 20, 2009, 1:30:21 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/lib/adl_parser/lib/adl_scanner.rb
r323 r324 3 3 require 'adl_parser.rb' 4 4 require 'open_ehr' 5 #require 'am.rb'6 #require 'rm.rb'7 5 require 'util.rb' 8 6 … … 53 51 'infinity' => :SYM_INFINITY # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY 54 52 } 55 REGEX_PATTERN = { 56 :V_ISO8601_DURATION => /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS 57 } 58 53 REGEX_PATTERN = Hash[:CarriageReturn => /\A\n/, 54 :WhiteSpace => /\A[ \t\r\f]+/, 55 :SingleCommentLine => /\A--.*/, 56 :V_ISO8601_DURATION => /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS 57 ] 58 59 59 def initialize(adl_type, filename, lineno = 1) 60 60 super(adl_type, filename, lineno) … … 71 71 when :adl 72 72 case data 73 when /\A\n/ # carriage return 73 # when /\A\n/ # carriage return 74 when REGEX_PATTERN[:CarriageReturn] # carriage return 74 75 @lineno += 1 75 76 ; 76 when /\A[ \t\r\f]+/ #just drop it 77 ; 78 when /\A--.*/ # single line comment 77 # when /\A[ \t\r\f]+/ #just drop it 78 when REGEX_PATTERN[:WhiteSpace] # carriage return 79 ; 80 # when /\A--.*/ # single line comment 81 when REGEX_PATTERN[:SingleCommentLine] # carriage return 79 82 @lineno += 1 80 83 @@logger.debug("ADLScanner#scan: COMMENT = #{$&} at #{@filename}:#{@lineno}") … … 243 246 # DADLScanner 244 247 # 245 class DADLScanner < Base248 class DADLScanner < ADLScanner 246 249 attr_accessor :in_interval, :in_c_domain_type, :dblock_depth 247 250 @@logger = OpenEhr::ADL::Scanner::LOGGER #Logger.new('log/scanner.log') … … 270 273 when :dadl 271 274 case data 272 when /\A\n/ # carriage return273 #@@logger.debug("DADLScanner#scan: carriage return, data = #{data.inspect}")275 # when /\A\n/ # carriage return 276 when REGEX_PATTERN[:CarriageReturn] # carriage return 274 277 @lineno += 1 275 278 ; 276 when /\A[ \t\r\f]+/ #just drop it 279 # when /\A[ \t\r\f]+/ #just drop it 280 when REGEX_PATTERN[:WhiteSpace] 277 281 ##@@logger.debug("DADLScanner#scan: white space, data = #{data.inspect}") 278 282 ; 279 when /\A--.*/ # single line comment 283 # when /\A--.*/ # single line comment 284 when REGEX_PATTERN[:SingleCommentLine] 280 285 @@logger.debug("DADLScanner#scan: COMMENT = #{$&} at #{@filename}:#{@lineno}") 281 286 ; … … 434 439 end # of DADLScanner 435 440 436 437 438 class CADLScanner < Base 441 class CADLScanner < ADLScanner 439 442 440 443 @@logger = OpenEhr::ADL::Scanner::LOGGER #Logger.new('log/scanner.log') #Logger.new('log/scanner.log') … … 483 486 when :cadl 484 487 case data 485 when /\A\n/ # carriage return 488 # when /\A\n/ # carriage return 489 when REGEX_PATTERN[:CarriageReturn] # carriage return 486 490 @lineno += 1 487 491 ; 488 492 #yield :CR, :CR 489 when /\A[ \t\r\f]+/ #just drop it 490 ; 491 when /\A--.*\n/ # single line comment 493 # when /\A[ \t\r\f]+/ #just drop it 494 when REGEX_PATTERN[:WhiteSpace] 495 ; 496 # when /\A--.*\n/ # single line comment 497 when REGEX_PATTERN[:SingleCommentLine] 492 498 @lineno += 1 493 499 ; … … 545 551 @@logger.debug("CADLScanner#scan: Slash_code #{@filename}:#{@lineno}") 546 552 yield :Slash_code, :Slash_code 547 # # yield :Slash_code, :Slash_code548 # # when /\A\// #V_REGEXP /549 # assert_at(__FILE__,__LINE__){@adl_type.last != :regexp}550 # #@in_regexp = true551 # @adl_type.push(:regexp)552 # # yield :START_REGEXP_BLOCK, :START_REGEXP_BLOCK553 554 553 when /\A\{\// # REGEXP_HEAD {/ 555 554 assert_at(__FILE__,__LINE__){ @adl_type.last != :regexp} … … 729 728 when :regexp 730 729 case data 731 # # when /\A\// #V_REGEXP /732 # when /\A([^\/]+)\// #V_REGEXP733 # assert_at(__FILE__,__LINE__){@adl_type.last == :regexp}734 # #@in_regexp = false735 # @adl_type.pop736 # @@logger.debug("#{__FILE__}:#{__LINE__}: RegexScanner::scan $1 = #{$1.inspect}")737 # # yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK738 # yield :V_REGEXP, $1739 # when /\A\/\}/ #V_REGEXP /740 # if @adl_type.last == :regexp741 # @in_regexp = false742 # @adl_type.pop743 # yield :END_REGEXP_BLOCK, :END_REGEXP_BLOCK744 # else745 # raise746 # end747 # when /\A(.*)(\/\})/ #V_REGEXP /}748 # when /\A(.*)\/\}/ # REGEXP_BODY749 730 when /\A(.*)\// # REGEXP_BODY 750 731 @adl_type.pop … … 813 794 assert_at(__FILE__,__LINE__){adl_type == :term_constraint} 814 795 yield :END_TERM_CODE_CONSTRAINT, $1 815 else816 raise "data = #{data}"796 # else 797 # raise "data = #{data}" 817 798 end 818 799 data = $' # variable $' receives the string after the match
Note:
See TracChangeset
for help on using the changeset viewer.