cmCTestResourceGroupsLexer.in.l 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. %{
  2. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  3. file Copyright.txt or https://cmake.org/licensing for details. */
  4. /*
  5. This file must be translated to C++ and modified to build everywhere.
  6. Run flex >= 2.6 like this:
  7. flex --nounistd -DFLEXINT_H --noline --header-file=cmCTestResourceGroupsLexer.h -ocmCTestResourceGroupsLexer.cxx cmCTestResourceGroupsLexer.in.l
  8. Modify cmCTestResourceGroupsLexer.cxx:
  9. - remove trailing whitespace: sed -i 's/\s*$//' cmCTestResourceGroupsLexer.h cmCTestResourceGroupsLexer.cxx
  10. - remove blank lines at end of file: sed -i '${/^$/d;}' cmCTestResourceGroupsLexer.h cmCTestResourceGroupsLexer.cxx
  11. - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmCTestResourceGroupsLexer.cxx
  12. */
  13. /* IWYU pragma: no_forward_declare yyguts_t */
  14. #ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
  15. #include "cmCTestResourceGroupsLexerHelper.h"
  16. #include <string>
  17. #include <cstddef>
  18. /*--------------------------------------------------------------------------*/
  19. %}
  20. %option prefix="cmCTestResourceGroups_yy"
  21. %option reentrant
  22. %option noyywrap
  23. %option nodefault
  24. %pointer
  25. %s RESOURCE_GROUPS_START
  26. %s RESOURCE_GROUPS_END
  27. %s RESOURCE_START
  28. %s RESOURCE_COUNT
  29. %s RESOURCE_END
  30. NUMBER [0-9]+
  31. IDENTIFIER [a-z_][a-z0-9_]*
  32. %%
  33. <INITIAL,RESOURCE_GROUPS_START,RESOURCE_START>{IDENTIFIER}: {
  34. BEGIN(RESOURCE_COUNT);
  35. yyextra->SetResourceType(std::string(yytext, yyleng - 1));
  36. }
  37. <INITIAL,RESOURCE_GROUPS_START>{NUMBER} {
  38. BEGIN(RESOURCE_GROUPS_END);
  39. std::size_t len = yyleng;
  40. yyextra->SetProcessCount(std::stoll(yytext, &len, 10));
  41. }
  42. <RESOURCE_COUNT>{NUMBER} {
  43. BEGIN(RESOURCE_END);
  44. std::size_t len = yyleng;
  45. yyextra->SetNeededSlots(std::stoll(yytext, &len, 10));
  46. yyextra->WriteRequirement();
  47. }
  48. <RESOURCE_GROUPS_END,RESOURCE_END>,+ {
  49. BEGIN(RESOURCE_START);
  50. }
  51. <INITIAL,RESOURCE_GROUPS_START,RESOURCE_START>;+ {
  52. BEGIN(RESOURCE_GROUPS_START);
  53. }
  54. <RESOURCE_GROUPS_END,RESOURCE_END>;+ {
  55. BEGIN(RESOURCE_GROUPS_START);
  56. yyextra->WriteProcess();
  57. }
  58. <RESOURCE_START,RESOURCE_GROUPS_END,RESOURCE_END><<EOF>> {
  59. yyextra->WriteProcess();
  60. return 0;
  61. }
  62. <INITIAL,RESOURCE_GROUPS_START><<EOF>> {
  63. return 0;
  64. }
  65. <<EOF>> {
  66. return 1;
  67. }
  68. .|\n {
  69. return 1;
  70. }
  71. %%
  72. /*--------------------------------------------------------------------------*/
  73. #endif /* __clang_analyzer__ */