cmDependsFortranLexer.in.l 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. %{
  2. /*=========================================================================
  3. Program: CMake - Cross-Platform Makefile Generator
  4. Module: $RCSfile$
  5. Language: C++
  6. Date: $Date$
  7. Version: $Revision$
  8. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  9. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  10. This software is distributed WITHOUT ANY WARRANTY; without even
  11. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12. PURPOSE. See the above copyright notices for more information.
  13. =========================================================================*/
  14. /*-------------------------------------------------------------------------
  15. Portions of this source have been derived from makefdep90 version 2.6.2,
  16. Copyright (C) 2000,2001 Erik Edelmann <[email protected]>.
  17. The code was originally distributed under the GPL but permission
  18. from the copyright holder has been obtained to distribute this
  19. derived work under the CMake license.
  20. -------------------------------------------------------------------------*/
  21. /*
  22. This file must be translated to C and modified to build everywhere.
  23. Run flex like this:
  24. flex -i --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.cxx cmDependsFortranLexer.in.l
  25. Modify cmDependsFortranLexer.cxx:
  26. - remove TABs
  27. - remove "yyscanner" argument from these methods:
  28. yy_fatal_error, cmDependsFortran_yyalloc, cmDependsFortran_yyrealloc, cmDependsFortran_yyfree
  29. - remove all YY_BREAK lines occurring right after return statements
  30. - change while ( 1 ) to for(;;)
  31. Modify cmDependsFortranLexer.h:
  32. - remove TABs
  33. - remove the yy_init_globals function
  34. - remove the block that includes unistd.h
  35. - remove #line directives (avoids bogus warning on old Sun)
  36. */
  37. #include "cmStandardLexer.h"
  38. #define cmDependsFortranLexer_cxx
  39. #include "cmDependsFortranParser.h" /* Interface to parser object. */
  40. /* Replace the lexer input function. */
  41. #undef YY_INPUT
  42. #define YY_INPUT(buf, result, max_size) \
  43. { result = cmDependsFortranParser_Input(yyextra, buf, max_size); }
  44. /* Include the set of tokens from the parser. */
  45. #include "cmDependsFortranParserTokens.h"
  46. /*--------------------------------------------------------------------------*/
  47. %}
  48. %option reentrant
  49. %option noyywrap
  50. %pointer
  51. %s free_fmt fixed_fmt
  52. %x str_sq str_dq
  53. %%
  54. \" {
  55. cmDependsFortranParser_StringStart(yyextra);
  56. BEGIN(str_dq);
  57. }
  58. ' {
  59. cmDependsFortranParser_StringStart(yyextra);
  60. BEGIN(str_sq);
  61. }
  62. <str_dq>\" |
  63. <str_sq>' {
  64. yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
  65. return STRING;
  66. }
  67. <str_dq,str_sq>&[ \t]*\n |
  68. <str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */
  69. <fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] /*Ignore (cont. strings, fixed fmt) */
  70. <str_dq,str_sq>\n {
  71. unput ('\n');
  72. BEGIN(INITIAL);
  73. return UNTERMINATED_STRING;
  74. }
  75. <str_sq,str_dq>. {
  76. cmDependsFortranParser_StringAppend(yyextra, yytext[0]);
  77. }
  78. !.*\n { return EOSTMT; } /* Treat comments like */
  79. <fixed_fmt>^[cC*dD].*\n { return EOSTMT; } /* empty lines */
  80. #[ \t]*include { return CPP_INCLUDE; }
  81. \$[ \t]*include { return F90PPR_INCLUDE; }
  82. \?\?[ \t]*include { return COCO_INCLUDE; }
  83. INCLUDE { return F_INCLUDE; }
  84. USE { return USE; }
  85. END" "*INTERFACE {
  86. cmDependsFortranParser_SetInInterface(yyextra, 0);
  87. }
  88. INTERFACE {
  89. cmDependsFortranParser_SetInInterface(yyextra, 1);
  90. }
  91. END" "*MODULE /* Ignore */
  92. MODULE {
  93. if(!cmDependsFortranParser_GetInInterface(yyextra))
  94. {
  95. return MODULE;
  96. }
  97. }
  98. #[ \t]*define { return CPP_DEFINE; }
  99. \$[ \t]*DEFINE { return F90PPR_DEFINE; }
  100. #[ \t]*undef { return CPP_UNDEF; }
  101. \$[ \t]*UNDEF { return F90PPR_UNDEF; }
  102. #[ \t]*ifdef { return CPP_IFDEF; }
  103. #[ \t]*ifndef { return CPP_IFNDEF; }
  104. #[ \t]*if { return CPP_IF; }
  105. #[ \t]*elif { return CPP_ELIF; }
  106. #[ \t]*else { return CPP_ELSE; }
  107. #[ \t]*endif { return CPP_ENDIF; }
  108. $[ \t]*ifdef { return F90PPR_IFDEF; }
  109. $[ \t]*ifndef { return F90PPR_IFNDEF; }
  110. $[ \t]*if { return F90PPR_IF; }
  111. $[ \t]*elif { return F90PPR_ELIF; }
  112. $[ \t]*else { return F90PPR_ELSE; }
  113. $[ \t]*endif { return F90PPR_ENDIF; }
  114. &[ \t]*\n |
  115. &[ \t]*\n[ \t]*& /* Ignore */
  116. [^ \t\n\r;,!'""']+ { yylvalp->string = strdup(yytext); return WORD; }
  117. ;|\n { return EOSTMT; }
  118. [ \t\r,] /* Ignore */
  119. . { return *yytext; }
  120. <<EOF>> {
  121. if(!cmDependsFortranParser_FilePop(yyextra))
  122. {
  123. return YY_NULL;
  124. }
  125. }
  126. %%
  127. /*--------------------------------------------------------------------------*/
  128. YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
  129. {
  130. /* Hack into the internal flex-generated scanner to get the buffer. */
  131. struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
  132. return YY_CURRENT_BUFFER;
  133. }