Sha256: cd5446975793e208c59757423a3cdd762c52cecf2001830a8ff1cfcce87a6d1b
Contents?: true
Size: 1.59 KB
Versions: 8
Compression:
Stored size: 1.59 KB
Contents
require_relative 'token_node' require_relative 'non_terminal_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 # for the parse that corresponds to the input text. In a parse tree, # a node corresponds to a grammar symbol used during the parsing: # - a leaf node maps to a terminal symbol occurring in # the input, and # - a intermediate node maps to a non-terminal node reduced # during the parse. # The root node corresponds to the main/start symbol of the grammar. class ParseForest # The root node of the forest attr_reader(:root) # A Hash with pairs of the kind node key => node attr_reader(:key2node) # @param theRootNode [ParseForestNode] The root node of the parse tree. def initialize(theRootNode) @root = theRootNode @key2node = {} end # Returns true if the given node is present in the forest. def include?(aNode) return key2node.include?(aNode) end # Part of the 'visitee' role in the Visitor design pattern. # A visitee is expected to accept the visit from a visitor object # @param aVisitor [ParseForestVisitor] the visitor object def accept(aVisitor) aVisitor.start_visit_pforest(self) # Let's proceed with the visit of nodes root.accept(aVisitor) if root aVisitor.end_visit_pforest(self) end end # class end # module end # module # End of file
Version data entries
8 entries across 8 versions & 1 rubygems