newsdev / archieml-js

JavaScript parser for the Archie Markup Language (ArchieML)
http://archieml.org
Other
206 stars 19 forks source link

Implicit Object Nesting #28

Closed john-michael-murphy closed 4 years ago

john-michael-murphy commented 4 years ago

Description

Current spec requires dot notation to nest properties in an object:

{object}
{object.a}
foo: foo
{object.a.b}
bar: bar
{object.a.b.c}
baz: baz

To reduce verbosity, this PR introduces implicit nesting. Objects declared with a . flag will nest inside the object's parent. Just like with nested arrays, objects must be closed with empty brackets to move up to a parent scope.

With this change, we can now simplify the above expression to the following:

{object}
{.a}
foo: foo
{.b}
bar: bar
{.c}
baz: baz

Preview

playground

Unit Tests

https://github.com/newsdev/archieml.org/pull/42/files

john-michael-murphy commented 4 years ago

@isaacwhite, sounds good to me! I've committed the suggestion.

yeefun commented 3 years ago

I wonder if the new version 0.5.0 has been published to npm?