Sha256: 65ecaaa73ced2c070e4b35b4fc39df210356bf15d26314ebf749949cf0dc19e9
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require_relative 'parse_tree_node' # Load superclass module Rley # This module is used as a namespace module PTree # This module is used as a namespace class TerminalNode < ParseTreeNode # Link to the input token attr_reader(:token) # aPosition is the position of the token in the input stream. def initialize(aToken, aPos) (major, minor) = # Use '1.class' trick to support both Integer and Fixnum classes range = aPos.kind_of?(1.class) ? { low: aPos, high: aPos + 1 } : aPos super(aToken.terminal, range) @token = aToken end # Emit a (formatted) string representation of the node. # Mainly used for diagnosis/debugging purposes. def to_string(indentation) return super + ": '#{token.lexeme}'" end # Emit a short string representation of the node. # Mainly used for diagnosis/debugging purposes. def to_s() return super + ": '#{token.lexeme}'" end # Part of the 'visitee' role in Visitor design pattern. # @param aVisitor[ParseTreeVisitor] the visitor def accept(aVisitor) aVisitor.visit_terminal(self) end end # class end # module end # module # End of file
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rley-0.4.07 | lib/rley/ptree/terminal_node.rb |