Just another blog about technology
JavaCC Grammar for Parsing DOT Files
Included here is a JavaCC grammar that can be used to parse instances of the DOT language. DOT is the language used by the wonderful graphviz suite of tools. I’ve used this grammar to both parse and generate instances of DOT interactively. Your mileage may vary, of course, but I hope you find it useful.
Technically, the grammer included here is a JJTree meta-grammar. That is, you begin with the dotparser.jjt grammer, run that file through the JJTree tool (part of the JavaCC distribution), and a dotparser.jj is produced. It is this .jj file that is the grammar compiled by JavaCC. The reason for the level of indirection - using the meta-grammar - is because I wanted to build an abstrct syntax tree from the DOT instance I was parsing. That’s just what JJTree does — builds a JavaCC grammar which constructs an AST as it parses.
I’ve included all of the generated files in the download in case you don’t want to run the JavaCC tools, but just realize that everthing was generated from the single dotparser.jjt file.
There are no restrictions on the use of this software, but equally, it is provided with no warranty or support.
Subscribe to RSS Feed