Module: Dhall::Parser::SingleQuoteLiteral

Defined in:
lib/dhall/parser.rb

Instance Method Summary collapse

Instance Method Details

#valueObject



322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/dhall/parser.rb', line 322

def value
  chunks = capture(:single_quote_continue).value.flat_map do |chunk|
    chunk.is_a?(String) ? chunk.gsub(/\r\n/, "\n").chars : chunk
  end
  indent = Util.indent_size(chunks.join)

  TextLiteral.for(
    *chunks
      .chunk { |c| c != "\n" }
      .flat_map { |(line, chunk)| line ? chunk[indent..-1] : chunk }
  )
end