in reply to Re: Parsing syntax trees
in thread Parsing syntax trees
Just WOW! Thank you very much for your responses! I had been away from Perl for a while, had not known about Marpa before.
If you insist, I'll tell something about this. I had not done this before 1) in the interest of keeping my question short and 2) by fear of being told that this is already done, and way better than I am capable of. Which is exactly what's going to ensue now. Trust me. So be it.
I am a lazy Computer Networks teacher. I want to have a minimalist language to describe a (computer) network topology and diagram layout. My idea is to cruft a file like
R:router S1:switch S2:switch H1:host H2:host H3:host R-S1 R-S2 H1-S1 H2-S1 H3-S2 R;(S1;(H1,H2)),(S2;H1)
This would describe a simple network where a router is linked to two switches, S1 linked to hosts H1 and H2, and then S2, linked to H3.
The first stances declare topology elements in association with some predefined icons. The middle part tells what's linked to what. The final line describes the diagram layout. In my mind "A;B" means A is graphically above B, and "A,B" means A is to the left of B. This final line is what I am trying to parse.
After having the syntax tree I want to apply some simple algorithms to get the bounding box dimensions for each subtree and finally draw the graph with properly centered icons and links.
I was not expecting binary trees as a result, I'll have to digest that. Maybe I'll be fine with them.
Thank you again!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Parsing syntax trees
by GrandFather (Saint) on Dec 30, 2015 at 22:21 UTC |