New for PyParsing. I am trying to figure out how to parse drawing attributes (and the like) in xdot files. There are a number of elements in which the number of the following elements is indicated as an integer at the beginning - similar to NetStrings. I looked at some code examples for working with netstring as constructors, but it doesn't seem to work for me.
Here are some examples:
Polygon with 3 points (3 after P indicates the number of following points):
P 3 811 190 815 180 806 185must be analyzed on'P', [[811, 190], [815, 180], [806, 185]]
Polygon with 2 points:
P 2 811 190 815 180 806 185must be analyzed on 'P', [[811, 190], [815, 180]](with undisclosed text at the end)
Pen fill color (4 after C indicates the number of characters after using “-”):
C 4 -blueshould be analyzed for'C', 'blue'
Updated information:
I think I was misleading by putting examples in my lines, without any extra context. Here is a real example:
S 5 -solid S 15 -setlinewidth(1) c 5 -black C 5 -black P 3 690 181 680 179 687 187
See http://www.graphviz.org/doc/info/output.html#d:xdot for the actual specification.
Please note that there may be significant spaces in the text fields. The setlinewidth (1) value above can be "abcd efgh hijk", and as long as it is exactly 15 characters, it must be associated with the "S" tag. There must be exactly 7 numbers (initial counter + 3 pairs) after the "P" tag, and everything else should raise a parsing error, as there may be more tags following (on one line), but the numbers themselves are not real.
Hope this simplifies things a bit.