Readme.txt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. JPlag Frontend Pack
  2. The JPlag system uses different frontends to transform the input files into a
  3. token stream, which abstracts very much from the original source code. For
  4. example in our Java frontend any assignments are translated to J_ASSIGN
  5. tokens, method invocations become J_APPLY tokens, arithmetic calculations,
  6. names, and comments are ignored, etc. Only some kind of program structure
  7. remains, which is then compared to other source files.
  8. This package contains a minimal set of files required to build our
  9. Java 1.4 frontend (including ANTLR 2.7.7). The jplag.Program class has been
  10. reduced to only two functions.
  11. The grammar is specified with ANTLR 2.7.7 (src/main/antlr/java.g). In
  12. some productions the parser adds tokens to the above mentioned token stream.
  13. Search for "parser.add(" to find these locations. The token types are defined
  14. in "src/main/java/jplag/java/JavaToken.java" and "src/main/java/jplag/java/JavaTokenConstants.java".
  15. After building the source with a simple "mvn compile", you can test the parser by
  16. invoking the main method of jplag.java.Parser with a Java file to parse as arguemtn:
  17. java -cp "antlr.jar;build" jplag.java.Parser src/main/java/jplag/java/Parser.java
  18. This will show you the listing of src/main/java/jplag/java/Parser.java on the right side
  19. of the screen with the generated tokens and their locations on the left side.
  20. To generate a new frontend you have to do the following things:
  21. - Generate an ANTLR 2.7.7 grammar (note: ANTLR 3 is quite different
  22. from ANTLR 2) -> this is done during mvn compile
  23. - Choose which tokens should be generated
  24. - Declare the token types in a ...Token.java and ...TokenConstants.java file
  25. - Add the tokens with "parser.add(..." in the grammar
  26. - Adapt the other files
  27. I hope this helps you to understand, how our frontends work and to create
  28. your own frontend.
  29. It is also possible to use another parser generator. Our Java 1.5 frontend
  30. for example uses JavaCC 3.2. If you are interested in using JavaCC, we can
  31. also provide you with the Java 1.5 frontend.