Build ASTs

Skip to end of metadata
Go to start of metadata

Your goal is to produce an AST from DOT input using an ANTLR grammar and AST construction operators and rewrite syntax. See the ANTLR reference guide, LIP, or the web documentation. From input

You must produce AST:

The only output of the program should be the toStringTree() output (which I've formatted here for clarity):

(digraph trees
  (CLUSTER
    (subgraph t
      (CLUSTER
        (-> 0 "1" (= label "A") (= color Blue))
        (-> 0 "2" (= label "B"))
      )
    )
    (subgraph u
      (CLUSTER
        (-> Animal Cat (= label "feline"))
        (-> Animal Dot (= label "canine"))
      )
    )
  )
)

Start with the grammar from Parsing Graphviz DOT files the hard way

You should put the main() directly in the @members section of your grammar: DOT.g. The only output should be the tree in text form.

Submission

You will create a jar file called ast.jar containing source and *.class files and place in your build directory:

https://www/svn/userid/cs652/ast/build/ast.jar

I will run your code by executing the following:

$java -cp "/home/username/cs652/ast/build/ast.jar:$CLASSPATH" DOTParser < test.dot

You can use the svn account for development of the software too if you would like, but I will only be looking at your jar file in the build directory.

For more information, see svn in CS601. Naturally you will have to substitute cs652 for cs601.

Labels: