Language.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package de.jplag;
  2. import java.io.File;
  3. /**
  4. * Common interface for all languages. Each language-front end must provide a concrete language implementation.
  5. */
  6. public interface Language {
  7. /**
  8. * Suffixes for the files containing code of the language. An empty array means all suffixes are valid.
  9. */
  10. String[] suffixes();
  11. /**
  12. * Descriptive name of the language.
  13. */
  14. String getName();
  15. /**
  16. * Identifier of the language for CLI options and for dynamic loading of language.
  17. */
  18. String getIdentifier();
  19. /**
  20. * Minimum number of tokens required for a match.
  21. */
  22. int minimumTokenMatch();
  23. /**
  24. * Parses a set files in a directory.
  25. * @param directory is the directory where the files are located.
  26. * @param files are the names of the files to parse.
  27. * @return the list of parsed JPlag tokens.
  28. */
  29. TokenList parse(File directory, String[] files);
  30. /**
  31. * Whether errors were found during the last {@link #parse}.
  32. */
  33. boolean hasErrors();
  34. /**
  35. * Determines whether the parser provide column information. If that is the case, line and column indices are used
  36. * instead of a single token index.
  37. */
  38. default boolean supportsColumns() {
  39. return true;
  40. }
  41. /**
  42. * Indicates whether the input files (code) should be used as representation in the report, or different files that form
  43. * a view on the input files.
  44. */
  45. default boolean useViewFiles() {
  46. return false;
  47. }
  48. /**
  49. * If the language uses representation files, this method returns the suffix used for the representation files.
  50. */
  51. default String viewFileSuffix() {
  52. return "";
  53. }
  54. }