lib/bel_parser/parsers/ast/node.rb in bel_parser-1.0.0.alpha.1 vs lib/bel_parser/parsers/ast/node.rb in bel_parser-1.0.0.alpha.2
- old
+ new
@@ -62,10 +62,20 @@
# Get the character range enclosing this AST node.
# It is defined as the close interval containing all the characters
# of this AST node.
attr_reader :character_range
+ # Get the syntax errors for this AST node.
+ def syntax_errors
+ (@syntax_errors ||= [])
+ end
+
+ # Add a syntax error to thie AST node.
+ def add_syntax_error(syntax_error)
+ syntax_errors << syntax_error
+ end
+
# Get the start of the character range enclosing this AST node.
def range_start
@character_range[0]
end
@@ -90,13 +100,13 @@
!@complete
end
def traverse(&block)
if block_given?
+ yield self
children.each do |child_node|
child_node.traverse(&block) if child_node.respond_to?(:traverse)
end
- yield self
else
enum_for(:traverse)
end
end