aboutsummaryrefslogtreecommitdiffstats
path: root/ast.rb
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2022-09-25 17:53:44 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2022-10-08 17:59:11 +0900
commitfbbdbdd8911ffb24d98bb71c7c33d24609ce7dfe (patch)
tree74e11b409521113dedae0e28e7013a22e61b8c3f /ast.rb
parent7775d14356c375536c915ea4bd0fae019acaaeb1 (diff)
downloadruby-fbbdbdd8911ffb24d98bb71c7c33d24609ce7dfe.tar.gz
Add error_tolerant option to RubyVM::AST
If this option is enabled, SyntaxError is not raised and Node is returned even if passed script is broken. [Feature #19013]
Diffstat (limited to 'ast.rb')
-rw-r--r--ast.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/ast.rb b/ast.rb
index f866bd23e5..24fd8e5526 100644
--- a/ast.rb
+++ b/ast.rb
@@ -29,8 +29,8 @@ module RubyVM::AbstractSyntaxTree
#
# RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9>
- def self.parse string, keep_script_lines: false
- Primitive.ast_s_parse string, keep_script_lines
+ def self.parse string, keep_script_lines: false, error_tolerant: false
+ Primitive.ast_s_parse string, keep_script_lines, error_tolerant
end
# call-seq:
@@ -44,8 +44,8 @@ module RubyVM::AbstractSyntaxTree
#
# RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb")
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3>
- def self.parse_file pathname, keep_script_lines: false
- Primitive.ast_s_parse_file pathname, keep_script_lines
+ def self.parse_file pathname, keep_script_lines: false, error_tolerant: false
+ Primitive.ast_s_parse_file pathname, keep_script_lines, error_tolerant
end
# call-seq:
@@ -63,8 +63,8 @@ module RubyVM::AbstractSyntaxTree
#
# RubyVM::AbstractSyntaxTree.of(method(:hello))
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-3:3>
- def self.of body, keep_script_lines: false
- Primitive.ast_s_of body, keep_script_lines
+ def self.of body, keep_script_lines: false, error_tolerant: false
+ Primitive.ast_s_of body, keep_script_lines, error_tolerant
end
# RubyVM::AbstractSyntaxTree::Node instances are created by parse methods in