Language.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. * Short name of the language used for CLI options.
  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. * Determines whether a fixed-width font should be used to display that language.
  43. */
  44. default boolean isPreformatted() {
  45. return true;
  46. }
  47. }