Request for Implementation: Java #9
A few tips from the past 12 months:
I didn't find the book style to be very helpful. For me, a thorough and unambiguous spec would be more useful - based on the actual spec, then I can choose my preferred approach. For me, SWIM test idea is clearer and more concise than the book idea (although, the separate test file in this repo is confusing, it's much easier to understand one with code in
The area of tree notation that I am confused about, based on the spec at https://github.com/treenotation/faq.treenotation.org/blob/master/spec.txt, is how I should handle nodes that look over-indented.
My suggestion to make implementing easier is to improve the SWIM by using JSON to handle bootstrapping problems. If we define a canonical JSON serialization of tree notation, we can use it to cross-check parsers in new languages. I think it would help if we can write a test like this:
The tests would attempt to parse the tree under
To help with bootstrapping, the test suite could be saved as both
Great idea! I don't know why I hadn't thought of that. I have this weird subset of JSON that is isomorphic to Tree Notation, which I think has been confusing the heck out of people, because they have been taking it for the canonical JSON form, when it's just really a tiny subset I find useful in certain niche situations.
I added that and shipped a new version of JTree now with the canonical JSON serialization form that you created above. I also added a new "toJson()" textarea to the "Sandbox" app for playing around with. And I added deep linking ability to the Sandbox so you can share test cases.
Here is your provided test case: https://jtree.treenotation.org/sandbox/#tree%0A%20parent%20dataword1%20dataword2%0A%20%20child%20childword1%20childword2
The "toJson()" box has the canonical form.
The "toGridJson()" box has Grid Notation, which is tree Notation without the "edgeSymbol" nor the concept of parent/children.
For the "over-indented" case, the 2nd edge symbol gets treated as just another symbol. After the current indent level has increased by one, the edge symbol is no longer special. Example: https://jtree.treenotation.org/sandbox/#tree%0A%20parent%0A%20%20%20child%20The%20%22over-indented%22%20child%20is%20the%20same%20as%20a%20normal%20child%2C%20with%20a%20blank%20first%20cell