Skip to content

Extending the parser to implement a custom DSL-like language #103

@springcomp

Description

@springcomp

@mhutch you have been very helpful in the past when I previously asked about this:
#84

You have referred me to sample code that I took as inspiration.
I am indeed able to extend the parser and create new custom nodes.

However, going back to my first scenario, I seem to be unable to override the default XAttribute whose values are hardcoded to be strings.
You specifically highlighted in the past that you used a two-phase parsing of attributes, instead of going through the extension points from the parser here. I would be very interested to understand if it is at all possible with the current code or if I’m missing something obvious.

I think what I’m after is being able to create DOMs like there:

  • XDocument
    • XElement
      • XAttribute
        • XAttributeValue (custom implementation possible)

Ideally, the XAttribute should have an XAttributeValue node that authors like myself could extend arbitrarily.

Another option, is like I’m trying in a proof-of-concept to add a generic XObject? Node { get; set; } property to XObject, giving it support for attaching any node. But that feels a bit kludgey.

Something like:

  • XDocument
    • XElement
      • XAttribute (XAttribute.Node is provided as an attach point for custom nodes)

Please, can you provide some helpful guidance?

If there is anything that needs to be slightly changed in the current code, I’m happy to try and propose a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions