examples/general/SRL/lib/regex/character.rb in rley-0.5.11 vs examples/general/SRL/lib/regex/character.rb in rley-0.5.12

- old
+ new

@@ -104,24 +104,10 @@ # Return the character as a String object def char() self.class.codepoint2char(@codepoint) end - # Conversion method re-definition. - # Purpose: Return the String representation of the expression. - # If the Character was initially from a text (the lexeme), then the lexeme is returned back. - # Otherwise the character corresponding to the codepoint is returned. - def to_str() - if lexeme.nil? - result = char() - else - result = lexeme.dup() - end - - return result - end - # Returns true iff this Character and parameter 'another' represent the same character. # [another] any Object. The way the equality is tested depends on the another's class # Example: # newOne = Character.new(?\u03a3) # newOne == newOne # true. Identity @@ -149,9 +135,25 @@ end # Return a plain English description of the character def explain() return "the character '#{to_str()}'" + end + + protected + + # Conversion method re-definition. + # Purpose: Return the String representation of the expression. + # If the Character was initially from a text (the lexeme), then the lexeme is returned back. + # Otherwise the character corresponding to the codepoint is returned. + def text_repr() + if lexeme.nil? + result = char() + else + result = lexeme.dup() + end + + return result end private # Convertion method that returns a codepoint for the given two characters (digram) escape sequence. # Recognized escaped characters are: \a (alarm, 0x07), \n (newline, 0xA), \ No newline at end of file