summaryrefslogtreecommitdiff
path: root/lib/prism/ffi.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prism/ffi.rb')
-rw-r--r--lib/prism/ffi.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb
index 36f1c398de..8324f722a7 100644
--- a/lib/prism/ffi.rb
+++ b/lib/prism/ffi.rb
@@ -72,7 +72,8 @@ module Prism
"pm_serialize_parse",
"pm_serialize_parse_comments",
"pm_serialize_lex",
- "pm_serialize_parse_lex"
+ "pm_serialize_parse_lex",
+ "pm_parse_success_p"
)
load_exported_functions_from(
@@ -268,6 +269,18 @@ module Prism
end
end
+ # Mirror the Prism.parse_success? API by using the serialization API.
+ def parse_success?(code, **options)
+ LibRubyParser.pm_parse_success_p(code, code.bytesize, dump_options(options))
+ end
+
+ # Mirror the Prism.parse_file_success? API by using the serialization API.
+ def parse_file_success?(filepath, **options)
+ LibRubyParser::PrismString.with(filepath) do |string|
+ parse_success?(string.read, **options, filepath: filepath)
+ end
+ end
+
private
# Convert the given options into a serialized options string.