Spec-Zone.ru › Ruby 3.4

модуль Prism::Serialize

Модуль, отвечающий за десериализацию результатов разбора.

Константы

MAJOR_VERSION

Основная версия prism, ожидаемая в сериализованных строках.

MINOR_VERSION

Дополнительная версия prism, ожидаемая в сериализованных строках.

PATCH_VERSION

Версия исправления prism, ожидаемая в сериализованных строках.

TOKEN_TYPES

Типы токенов, которые можно индексировать по их значениям перечисления.

Общедоступные методы класса

load (input, serialized)
Исходный код
# File lib/prism/serialize.rb, line 28
def self.load(input, serialized)
  input = input.dup
  source = Source.for(input)

  loader = Loader.new(source, serialized)
  result = loader.load_result

  input.force_encoding(loader.encoding)

  # This is an extremely niche use-case where the file was marked as binary
  # but it contained UTF-8-encoded characters. In that case we will actually
  # put it back to UTF-8 to give the location APIs the best chance of being
  # correct.
  if !input.ascii_only? && input.encoding == Encoding::BINARY
    input.force_encoding(Encoding::UTF_8)
    input.force_encoding(Encoding::BINARY) unless input.valid_encoding?
  end

  result
end

Десериализует AST, представленный заданной строкой, в результат разбора.

load_tokens (source, serialized)
Исходный код
# File lib/prism/serialize.rb, line 51
def self.load_tokens(source, serialized)
  Loader.new(source, serialized).load_tokens_result
end

Десериализует токены, представленные заданной строкой, в результат разбора.

Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API