cscorley / srcmlolol

srcMLOLOL
MIT License
4 stars 3 forks source link

srcMLOLOL

srcMLOLOL is a proof-of-concept to write a more general srcML that uses ANTLR 4 and any given grammar to parse source code into XML.

Why

srcML relies on a heavily customized ANTLR 2 grammar with loads of actions to build XML representations of an AST. This customization means that supporting any more languages outside of the C-like will be difficult and expensive. Indeed, maintenance and development costs for srcML is already expensive. Unfortunately, not all software is written in C-like languages, severely limiting the scope of applications srcML has for software engineering research.

More recent versions of ANTLR provide listeners and visitors. srcMLOLOL will solve the language support issue by relying on a listener to emit XML.

Usage

  1. Compile grammar with ANTLR4:

    antlr4 Java.g4
    javac *.java
  2. Compile and run srcMLOLOL:

    ant
    java -jar dist/srcMLOLOL.jar Java Lol.java

All XML will be written to stdout.

Note that this example used the Java grammar, but it's not required! Use whichever grammar you want. srcMLOLOL doesn't care.