lisplang.l 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. %{
  2. /* This file is part of the software similarity tester SIM.
  3. Written by Dick Grune, Vrije Universiteit, Amsterdam.
  4. $Id: lisplang.l,v 2.9 2007/08/29 09:10:33 dick Exp $
  5. */
  6. /*
  7. LISP language front end for the similarity tester.
  8. Author: Gertjan Akkerman <[email protected]>
  9. Date: Thu, 9 Apr 87 11:15:23 MDT
  10. */
  11. #include "language.h"
  12. #include "token.h"
  13. #include "lex.h"
  14. #include "lang.h"
  15. /* Language-dependent Code */
  16. #include "idf.h"
  17. static const struct idf reserved[] = {
  18. {"append", NORM('a')},
  19. {"append1", NORM('b')},
  20. {"atom", NORM('t')},
  21. {"car", NORM('h')},
  22. {"cdr", NORM('t')},
  23. {"cond", NORM('c')},
  24. {"cons", NORM('s')},
  25. {"defun", NORM('u')},
  26. {"do", NORM('d')},
  27. {"eq", NORM('e')},
  28. {"equal", NORM('e')}, /* See eq */
  29. {"for", NORM('f')},
  30. {"if", NORM('i')},
  31. {"list", NORM('l')},
  32. {"nconc", NORM('n')},
  33. {"rplaca", NORM('A')},
  34. {"rplacd", NORM('D')}
  35. };
  36. /* Token sets for module algollike */
  37. const TOKEN NonFinals[] = {
  38. NORM('('),
  39. NORM('['),
  40. NOTOKEN
  41. };
  42. const TOKEN NonInitials[] = {
  43. NORM(')'),
  44. NORM(']'),
  45. NOTOKEN
  46. };
  47. const TOKEN Openers[] = {
  48. NORM('('),
  49. NORM('['),
  50. NOTOKEN
  51. };
  52. const TOKEN Closers[] = {
  53. NORM(')'),
  54. NORM(']'),
  55. NOTOKEN
  56. };
  57. %}
  58. %option nounput
  59. %option never-interactive
  60. %Start Comment
  61. Layout ([ \t\r\f])
  62. ASCII95 ([- !"#$%&'()*+,./0-9:;<=>?@A-Z\[\\\]^_`a-z{|}~])
  63. AnyQuoted (\\.)
  64. StrChar ([^"\n\\]|{AnyQuoted})
  65. ChrChar ([^'\\]|{AnyQuoted})
  66. IdfChar ([-!#$%&*+,/0-9:;<=>?@A-Z\\^_`a-z{}~])
  67. EscIdf (({IdfChar}|\\.)+)
  68. QuotIdf ("|"[^\|\n]*"|")
  69. Idf ({EscIdf}|{QuotIdf})
  70. %%
  71. ";".*$ { /* comment */
  72. }
  73. \"{StrChar}*\" { /* strings */
  74. return_ch('"');
  75. }
  76. {Idf} { /* identifier */
  77. return_tk(idf_in_list(yytext, reserved, sizeof reserved, IDF));
  78. }
  79. \n { /* count newlines */
  80. return_eol();
  81. }
  82. {Layout} { /* ignore layout */
  83. }
  84. {ASCII95} { /* copy other text */
  85. return_ch(yytext[0]);
  86. }
  87. . { /* count non-ASCII chars */
  88. lex_non_ascii_cnt++;
  89. }
  90. %%
  91. /* Language-INdependent Code */
  92. void
  93. yystart(void) {
  94. BEGIN INITIAL;
  95. }
  96. int
  97. yywrap(void) {
  98. return 1;
  99. }