I’ve created a pull parser as part of my OmniXaml project. It reads an XML file and transforms it into an enumerable of XAML Nodes. Now, my goal is to do it a more elegant parser using Sprache. The thing is that I don’t even know how to start. XAML parsing heavily relies on context, so if you want yield one Xaml Node, you might have to look-ahead and process the following nodes. I currently use an XmlReader to read the XAML.
This is an example of an input/output for you to figure out what I want to do: Input (XAML):
<DummyClass xmlns="root">
<DummyClass.Child>
<ChildClass></ChildClass>
</DummyClass.Child>
</DummyClass>
Output (list of XAML Nodes):
- Namespace Declaration of "root" with prefix: ""
- Start of Object of type DummyClass
- None
- Start of Member “Child” from type “DummyClass”
- Start of Object of type ChildClass
- None
- End of Object
- End of Member
- End of Object
Another example.
Input:
<DummyClass xmlns="root">
<DummyClass.Items>
<Item/>
<Item/>
<Item/>
</DummyClass.Items>
</DummyClass>
Output:
- Namespace Declaration of "root" with prefix: ""
- Start of Object of type DummyClass
- None
- Start of Member “Items” from type “DummyClass”
- [Get Object] Directive
- [Start of Items] Directive
- Start of Object of type “Item”
- None
- End of Object
- Start of Object of type “Item”
- None
- End of Object
- Start of Object of type “Item”
- None
- End of Object
- End of Member
- End of Object
- End of Member
- End of Object
The question: How to start with this?
Could you provide me with some samples/guidelines? Thanks!