I have a custom file format for graphs which looks like this:
node1.link1 : node2
node1.attribute1 : an_attribute_for_node1
node2.my_attribute1 : an_attribute_for_node2
(there is nothing special about the attributes names, an attribute is a link iff one can find its value at the left of a dot. So node2 is a link, because there is a line somewhere in the file that begins with node2.<something>).
I would like to highlight the attribute values if they are links (so I would like to highlight node2, but not attribute_for_node1).
Obviously, this kind of syntax highlighting cannot be based only on line wide regexp, because one needs to read the entire file to do the correct highlighting.
I already have a python parser for this kind of files (which gives a dict of dict string -> (string -> string)), but I don't know if python can interact with syntax highlighting in vim 7.
EDIT As a clarification, the dictionary produced for this example is:
d = {
'node1': {'link1' : 'node2', 'attribute1' : 'an_attribute_for_node1'},
'node2': {'attribute2': 'an_attribute_for_node2'}
}
By definition, l is a link for node n if and only if:
d[n][l] in d
Names are meaningless, the format is only structure dependant, and there is no language keywords.
I would like to highlight node2 in the first line, because it is the name for a node.
I hope it is clearer now.
Someone has an idea ?