textlang.l 986 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. %{
  2. /* This file is part of the software similarity tester SIM.
  3. Written by Dick Grune, Vrije Universiteit, Amsterdam.
  4. $Id: textlang.l,v 1.3 2007/08/29 09:10:36 dick Exp $
  5. */
  6. /*
  7. Text front end for the similarity tester.
  8. */
  9. #include "language.h"
  10. #include "token.h"
  11. #include "idf.h"
  12. #include "lex.h"
  13. #include "lang.h"
  14. /* Language-dependent Code */
  15. void
  16. InitLanguage(void) {
  17. }
  18. /*ARGSUSED*/
  19. int
  20. MayBeStartOfRun(TOKEN tk) {
  21. /* any token is acceptable */
  22. return 1;
  23. }
  24. /*ARGSUSED*/
  25. unsigned int
  26. CheckRun(const TOKEN *str, unsigned int size) {
  27. /* any run is acceptable */
  28. return size;
  29. }
  30. %}
  31. %option nounput
  32. %option never-interactive
  33. Layout ([ \t\r\f])
  34. %%
  35. [^ \t\n]+ { /* a word */
  36. /* a word is defined as anything not containing
  37. layout
  38. */
  39. return_tk(idf_hashed(yytext));
  40. }
  41. \n { /* count newlines */
  42. return_eol();
  43. }
  44. {Layout} { /* ignore layout */
  45. }
  46. %%
  47. /* Language-INdependent Code */
  48. void
  49. yystart(void) {
  50. BEGIN INITIAL;
  51. }
  52. int
  53. yywrap(void) {
  54. return 1;
  55. }