i wanna get a xml representation of the ast of java and c code. 3 months ago, i asked this question yet but the solutions weren\'t comfortable for me
srcml supports line number and column number. Here is an example using a java file called input.java (keep in mind srcml supports multiple languages, including C/C++) that contains the following:
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
Then run srcml with the command to enable keeping track of this extra position information:
srcml input.java --position
It produces the following AST in an XML format with line number and column number embedded:
public class HelloWorld {
public static void main (String [] args ) {
// Prints "Hello, World" to the terminal window.
System . out . println ("Hello, World" ) ;
}
}
Reference: Documentation for srcml v0.9.5 (see srcml --help). I also use srcml frequently, including this feature to obtain position information.