lib/prism/ffi.rb in prism-0.18.0 vs lib/prism/ffi.rb in prism-0.19.0

- old
+ new

@@ -70,11 +70,12 @@ "prism.h", "pm_version", "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( "prism/util/pm_buffer.h", "pm_buffer_sizeof", @@ -252,20 +253,32 @@ source = Source.new(code) loader = Serialize::Loader.new(source, buffer.read) tokens = loader.load_tokens - node, comments, magic_comments, errors, warnings = loader.load_nodes + node, comments, magic_comments, data_loc, errors, warnings = loader.load_nodes tokens.each { |token,| token.value.force_encoding(loader.encoding) } - ParseResult.new([node, tokens], comments, magic_comments, errors, warnings, source) + ParseResult.new([node, tokens], comments, magic_comments, data_loc, errors, warnings, source) end end # Mirror the Prism.parse_lex_file API by using the serialization API. def parse_lex_file(filepath, **options) LibRubyParser::PrismString.with(filepath) do |string| parse_lex(string.read, **options, filepath: filepath) + 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