Mirror of espurna firmware for wireless switches and more
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
3.3 KiB

  1. /* Generated by re2c 3.0 */
  2. #line 1 "espurna/led_pattern.re"
  3. /*
  4. LED MODULE
  5. Copyright (C) 2020-2021 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
  6. */
  7. #pragma once
  8. // Scans input string with format
  9. // '<on1>,<off1>,<repeats1> <on2>,<off2>,<repeats2> ...'
  10. // And returns a list of Delay objects for the pattern
  11. Pattern::Pattern(espurna::StringView value) {
  12. const char* on1;
  13. const char* on2;
  14. const char* off1;
  15. const char* off2;
  16. const char* repeat1;
  17. const char* repeat2;
  18. const char* YYCURSOR { value.begin() };
  19. const char* YYLIMIT { value.end() };
  20. const char* YYMARKER;
  21. loop:
  22. #line 33 "espurna/led_pattern.re.ipp"
  23. const char *yyt1;const char *yyt2;const char *yyt3;
  24. #line 30 "espurna/led_pattern.re"
  25. #line 38 "espurna/led_pattern.re.ipp"
  26. {
  27. char yych;
  28. yych = (char)*YYCURSOR;
  29. switch (yych) {
  30. case '\t':
  31. case ' ': goto yy3;
  32. case '0' ... '9':
  33. yyt1 = YYCURSOR;
  34. goto yy5;
  35. default:
  36. if (YYLIMIT <= YYCURSOR) goto yy13;
  37. goto yy1;
  38. }
  39. yy1:
  40. ++YYCURSOR;
  41. yy2:
  42. #line 44 "espurna/led_pattern.re"
  43. { return; }
  44. #line 57 "espurna/led_pattern.re.ipp"
  45. yy3:
  46. yych = (char)*++YYCURSOR;
  47. switch (yych) {
  48. case '\t':
  49. case ' ': goto yy3;
  50. default: goto yy4;
  51. }
  52. yy4:
  53. #line 46 "espurna/led_pattern.re"
  54. { goto loop; }
  55. #line 68 "espurna/led_pattern.re.ipp"
  56. yy5:
  57. yych = (char)*(YYMARKER = ++YYCURSOR);
  58. switch (yych) {
  59. case ',': goto yy6;
  60. case '0' ... '9': goto yy8;
  61. default: goto yy2;
  62. }
  63. yy6:
  64. yych = (char)*++YYCURSOR;
  65. switch (yych) {
  66. case '0' ... '9':
  67. yyt2 = YYCURSOR;
  68. goto yy9;
  69. default: goto yy7;
  70. }
  71. yy7:
  72. YYCURSOR = YYMARKER;
  73. goto yy2;
  74. yy8:
  75. yych = (char)*++YYCURSOR;
  76. switch (yych) {
  77. case ',': goto yy6;
  78. case '0' ... '9': goto yy8;
  79. default: goto yy7;
  80. }
  81. yy9:
  82. yych = (char)*++YYCURSOR;
  83. switch (yych) {
  84. case ',': goto yy10;
  85. case '0' ... '9': goto yy9;
  86. default: goto yy7;
  87. }
  88. yy10:
  89. yych = (char)*++YYCURSOR;
  90. switch (yych) {
  91. case '0' ... '9':
  92. yyt3 = YYCURSOR;
  93. goto yy11;
  94. default: goto yy7;
  95. }
  96. yy11:
  97. yych = (char)*++YYCURSOR;
  98. switch (yych) {
  99. case '0' ... '9': goto yy11;
  100. default: goto yy12;
  101. }
  102. yy12:
  103. on1 = yyt1;
  104. off1 = yyt2;
  105. repeat1 = yyt3;
  106. on2 = yyt2 - 1;
  107. off2 = yyt3 - 1;
  108. repeat2 = YYCURSOR;
  109. #line 48 "espurna/led_pattern.re"
  110. {
  111. const auto on = parseUnsigned(StringView(on1, on2), 10);
  112. if (!on.ok) {
  113. return;
  114. }
  115. const auto off = parseUnsigned(StringView(off1, off2), 10);
  116. if (!off.ok) {
  117. return;
  118. }
  119. using Repeats = Delay::Repeats;
  120. constexpr Repeats RepeatsMax { Delay::RepeatsMax };
  121. const auto repeats = parseUnsigned(StringView(repeat1, repeat2), 10);
  122. if (!repeats.ok) {
  123. return;
  124. }
  125. _delays.emplace_back(
  126. std::min(duration::Milliseconds(on.value), Delay::MillisecondsMax),
  127. std::min(duration::Milliseconds(off.value), Delay::MillisecondsMax),
  128. std::min(repeats.value, RepeatsMax));
  129. if (repeats.value) {
  130. goto loop;
  131. }
  132. }
  133. #line 149 "espurna/led_pattern.re.ipp"
  134. yy13:
  135. #line 43 "espurna/led_pattern.re"
  136. { return; }
  137. #line 153 "espurna/led_pattern.re.ipp"
  138. }
  139. #line 74 "espurna/led_pattern.re"
  140. }