Skip to content
This repository has been archived by the owner on Apr 19, 2020. It is now read-only.

Implement unquoting #13

Closed
wants to merge 5 commits into from
Closed

Conversation

limansky
Copy link

Hi,

I've tried to implement unquoting. This code is definitely not production ready, but just to show my vision on how it might be implemented. My approach is quite different than it is done in #12. I tried to avoid hacking strings. It is easy for content, but I'm still thinking how to deal with attributes, because both Metadata and NamespaceBinding expect string values at the construction time. I think, I can inherit these classes to show that here is a hole and it will be substituted later (of course it requires quite a lot of coding because of how scala-xml parsers implemented) . Another approach is to put strings into the Hole, but I'm not sure how to decompose AST properly to cover all cases (literals, variables, calls, etc), if it possible.

Please, add your comments and suggestions.

@limansky
Copy link
Author

I've slept on it and I think that we need to implement own model classes for XML, and the parser inherited from MarkupParserBase. Of course these classes will be converted to scala-xml Nodes on lifting stage.

Even though it requires some extra coding, it will save us from hacking in future when we will implement error handling and possible some other stuff. I'll try to prototype it this week.

@limansky
Copy link
Author

Actually I was able to make the rest of the tests working within this approach.

@limansky limansky changed the title Element content unquote Implement unquoting Mar 19, 2017
@allanrenucci
Copy link
Contributor

test("reconstruct unquote within namespaced elem") {
  val foo = xml"""<foo xmlns:pre=${"foo" + "bar"}/>"""
  val bar = <foo xmlns:pre={"foo" + "bar"}/>
  assert(foo.scope == bar.scope)
}

You'll still fail this test case though. As you said previously, we'll probably have to implement our own xml syntax tree

@limansky
Copy link
Author

@allanrenucci Good catch!

The problem is what in case of using of another model, we'll need to have our own parser, because MarkupParser is too much coupled with scala.xml model.

@allanrenucci
Copy link
Contributor

@limansky limansky closed this Apr 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants