class Rley::RGN::RepetitionNode
A RGN
syntax node representing an expression quantified by a ?, * or +.
Constants
- Repetition2suffix
Attributes
@return [Symbol] one of: :zero_or_one, :zero_or_more, :one_or_more
Public Class Methods
Source
# File lib/rley/rgn/repetition_node.rb, line 21 def initialize(child, theRepetition) super([child]) @repetition = theRepetition end
@param child [Array<ASTNode>] sequence of AST nodes @param theRepetition [Symbol] how many times the child node can be repeated
Calls superclass method
Rley::RGN::CompositeNode::new
Public Instance Methods
Source
# File lib/rley/rgn/repetition_node.rb, line 45 def accept(visitor) visitor.visit_repetition_node(self) end
Part of the ‘visitee’ role in Visitor design pattern. @param visitor [RGN::ASTVisitor] the visitor
Source
# File lib/rley/rgn/repetition_node.rb, line 27 def child subnodes[0] end
@return [RGN::ASTNode]
Source
# File lib/rley/rgn/repetition_node.rb, line 32 def name child_name = subnodes[0].name "rep_#{child_name}#{Repetition2suffix[repetition]}" end
@return [String]
Source
# File lib/rley/rgn/repetition_node.rb, line 57 def suffix_plus Repetition2suffix[:one_or_more] end
Source
# File lib/rley/rgn/repetition_node.rb, line 49 def suffix_qmark Repetition2suffix[:zero_or_one] end
Source
# File lib/rley/rgn/repetition_node.rb, line 53 def suffix_star Repetition2suffix[:zero_or_more] end
Source
# File lib/rley/rgn/repetition_node.rb, line 38 def to_text child_text = subnodes[0].to_text "rep_#{child_text}#{Repetition2suffix[repetition]}" end
@return [String]