Skip to content

Instantly share code, notes, and snippets.

@ljcooke
Last active August 18, 2019 11:02
Show Gist options
  • Save ljcooke/fb368e212aea668e2107acee18b6db37 to your computer and use it in GitHub Desktop.
Save ljcooke/fb368e212aea668e2107acee18b6db37 to your computer and use it in GitHub Desktop.
Example of parsing invalid Indental source with Nodaire::Indental.
> require 'nodaire/indental'
# true
> source = <<~NDTL
NAME
KEY : VALUE
key : duplicate
wrong indent level
NDTL
> doc = Nodaire::Indental.parse(source)
> doc.valid?
# false
> doc.errors.each { |e| warn e }
# Duplicate key on line 3
# No list specified on line 4
> doc = Nodaire::Indental.parse!(source)
# Traceback (most recent call last):
# [...]
# Nodaire::ParserError (Duplicate key on line 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment