lib/rley/ptree/token_range.rb in rley-0.2.15 vs lib/rley/ptree/token_range.rb in rley-0.3.00

- old
+ new

@@ -1,7 +1,15 @@ module Rley # This module is used as a namespace module PTree # This module is used as a namespace + # A token range (also called an extent) represents an interval + # of token positions that is matched by a given grammar symbol. + # For instance consider the expression E: 3 + 11, + # let's assume that the integer literal '3' is the fifth input token and + # that the '+' and '11' tokens are respectively at position 6 and 7; + # then the token range associated with E is [5, 7] + # While the parse tree/forest is being constructed the boundaries of the token range + # can be temporarily undefined (= set to nil) class TokenRange # The index of the lower bound of token range attr_reader(:low) # The index of the upper bound of token range @@ -56,10 +64,15 @@ def to_string(_indentation) low_text = low.nil? ? '?' : low.to_s high_text = high.nil? ? '?' : high.to_s return "[#{low_text}, #{high_text}]" - end + end + + # Generate a String that represents a value-based identifier + def keystr() + return "#{low.object_id}-#{high.object_id}" + end private def assign_low(aRange) case aRange