lib/rley/sppf/parse_forest.rb in rley-0.3.09 vs lib/rley/sppf/parse_forest.rb in rley-0.3.10

- old
+ new

@@ -1,7 +1,8 @@ require_relative 'token_node' require_relative 'non_terminal_node' +require_relative 'alternative_node' module Rley # This module is used as a namespace module SPPF # This module is used as a namespace # TODO change comment # A parse tree (a.k.a. concrete syntax tree) is a tree-based representation @@ -16,19 +17,30 @@ # The root node of the forest attr_reader(:root) # A Hash with pairs of the kind node key => node attr_reader(:key2node) + + # A setter that tells that the parse is ambiguous. + attr_writer(:is_ambiguous) + # @param theRootNode [ParseForestNode] The root node of the parse tree. def initialize(theRootNode) @root = theRootNode @key2node = {} + @is_ambiguous = false end # Returns true if the given node is present in the forest. def include?(aNode) return key2node.include?(aNode) + end + + # Returns true if the parse encountered a structural ambiguity + # (i.e. more than one parse tree for the given input) + def ambiguous?() + return @is_ambiguous end # Part of the 'visitee' role in the Visitor design pattern. # A visitee is expected to accept the visit from a visitor object