Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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!


In reply to Re^2: Parsing syntax trees by betacentauri
in thread Parsing syntax trees by betacentauri

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-18 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found