cmDependsFortranLexer.in.l 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 makedepf90 version 2.8.8,
  16. Copyright (C) 2000--2006 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. cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
  57. BEGIN(str_dq);
  58. }
  59. ' {
  60. cmDependsFortranParser_StringStart(yyextra);
  61. cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
  62. BEGIN(str_sq);
  63. }
  64. <str_dq>\" |
  65. <str_sq>' {
  66. BEGIN(cmDependsFortranParser_GetOldStartcond(yyextra) );
  67. yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
  68. return STRING;
  69. }
  70. <str_dq,str_sq>&[ \t]*\n |
  71. <str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */
  72. <fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] {
  73. if (cmDependsFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
  74. ; /* Ignore (cont. strings, fixed fmt) */
  75. else
  76. {
  77. unput(yytext[strlen(yytext)-1]);
  78. }
  79. }
  80. <str_dq,str_sq>\n {
  81. unput ('\n');
  82. BEGIN(INITIAL);
  83. return UNTERMINATED_STRING;
  84. }
  85. <str_sq,str_dq>. {
  86. cmDependsFortranParser_StringAppend(yyextra, yytext[0]);
  87. }
  88. !.*\n { return EOSTMT; } /* Treat comments like */
  89. <fixed_fmt>^[cC*dD].*\n { return EOSTMT; } /* empty lines */
  90. ^[ \t]*#[ \t]*include { return CPP_INCLUDE; }
  91. \$[ \t]*include { return F90PPR_INCLUDE; }
  92. \?\?[ \t]*include { return COCO_INCLUDE; }
  93. ^[ \t]*#[ \t]*define { return CPP_DEFINE; }
  94. \$[ \t]*DEFINE { return F90PPR_DEFINE; }
  95. ^[ \t]*#[ \t]*undef { return CPP_UNDEF; }
  96. \$[ \t]*UNDEF { return F90PPR_UNDEF; }
  97. ^[ \t]*#[ \t]*ifdef { return CPP_IFDEF; }
  98. ^[ \t]*#[ \t]*ifndef { return CPP_IFNDEF; }
  99. ^[ \t]*#[ \t]*if { return CPP_IF; }
  100. ^[ \t]*#[ \t]*elif { return CPP_ELIF; }
  101. ^[ \t]*#[ \t]*else { return CPP_ELSE; }
  102. ^[ \t]*#[ \t]*endif { return CPP_ENDIF; }
  103. $[ \t]*ifdef { return F90PPR_IFDEF; }
  104. $[ \t]*ifndef { return F90PPR_IFNDEF; }
  105. $[ \t]*if { return F90PPR_IF; }
  106. $[ \t]*elif { return F90PPR_ELIF; }
  107. $[ \t]*else { return F90PPR_ELSE; }
  108. $[ \t]*endif { return F90PPR_ENDIF; }
  109. /* Line continuations, possible involving comments. */
  110. &([ \t\n]*|!.*)*
  111. &([ \t\n]*|!.*)*&
  112. , { return COMMA; }
  113. :: { return DCOLON; }
  114. <fixed_fmt>\n[ ]{5}[^ ] { return GARBAGE; }
  115. =|=> { return ASSIGNMENT_OP; }
  116. [a-zA-Z_][a-zA-Z_0-9]* {
  117. yylvalp->string = strdup(yytext);
  118. return WORD;
  119. }
  120. [^ \t\n\r;,!'"a-zA-Z=&]+ { return GARBAGE; }
  121. ;|\n { return EOSTMT; }
  122. [ \t\r,] /* Ignore */
  123. \\[ \t]*\n /* Ignore line-endings preceeded by \ */
  124. . { return *yytext; }
  125. <<EOF>> {
  126. if(!cmDependsFortranParser_FilePop(yyextra) )
  127. {
  128. return YY_NULL;
  129. }
  130. }
  131. %%
  132. /*--------------------------------------------------------------------------*/
  133. YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
  134. {
  135. /* Hack into the internal flex-generated scanner to get the buffer. */
  136. struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
  137. return YY_CURRENT_BUFFER;
  138. }