Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How much of Hocon should we support #1164

Closed
rogeralsing opened this issue Jul 17, 2015 · 2 comments
Closed

How much of Hocon should we support #1164

rogeralsing opened this issue Jul 17, 2015 · 2 comments

Comments

@rogeralsing
Copy link
Contributor

I've been looking into the Hocon spec a bit more and some of the stuff in there are just crazy.

We do support substitutions already, but according to the Hocon spec, substitutions should be able to self reference

a : some value
a : {$a} and some more
a : {$a} and even more

In the above case the result should be "some value and some more and even more"
There is some conflicting info in the spec saying that substitutions should be done at the end, after all files have been included and parsed.
Which means that somehow, the parser result should remember all three of those lines.

The next part is includes.

a : { x : 123 }
a : { include 'somefile.bar' }

In the above case, the contents of somefile.bar should be merged with the existing value of a, which means that we probably have to load the other files during parsing, and prepend the result onto the string that is being parsed.

And to combine the two into a joy of brain pain.
somefile.bar can contain substitutions that ar relative to the document itself when loaded, but once inserted into the including config, the paths should be rewritten relative to the place where they are inserted into the inserting config.

I really don't want to change the parser to some multi pass parser that does the same'ish thing over and over untill the final config is produced.

So which of these features do we need? should we just let this be for the moment?

@rogeralsing
Copy link
Contributor Author

I've actually got some progress on this, we can resolve includes, and fixup substitutions in includes.
Not sure what to do with the self ref substitutions though.

The include resolver is a Func<string, HoconRoot> which we can optionally pass to the ConfiguratonFactory.ParseString, we can use this to resolve external configs as long as we return a hocon object back.

I also realized that since Hocon is a superset of json, we can serialize .NET objects to json, and then parse the json as hocon.
Which allows us to create typed objects that can be turned into config objects with a single method call.

So this will probably open up for some nice use cases

@rogeralsing
Copy link
Contributor Author

This has been merged.
Will open up a separate issue if we ever think we need self referencing substitutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants