void genSetCondition(OutputFile & o, uint32_t ind, const std::string& newcond)
{
- o.warn_condition_order = false; // see note [condition order]
if (bUseYYSetConditionParam)
{
o << indent(ind) << mapCodeName["YYSETCONDITION"] << "(" << condEnumPrefix << newcond << ");\n";
*
* re2c warns about implicit assumptions about condition order, unless:
* - condition type is defined with 'types:re2c' or '-t, --type-header'
- * - condition names are explicitly used in dispatch or YYSETCONDITION
- * - dispatch shrinks to single unconditional jump
+ * - dispatch is independent of condition order: either it uses
+ * explicit condition names or there's only one condition and
+ * dispatch shrinks to unconditional jump
*/
void genCondGoto(OutputFile & o, uint32_t ind, const std::vector<std::string> & condnames)
{
re2c: warning: line 3: rule matches empty string [-Wmatch-empty-string]
re2c: warning: line 9: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow]
re2c: warning: line 9: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 9: looks like you use hardcoded numbers instead of autogenerated condition names: better add '/*!types:re2c*/' directive or '-t, --type-header' option and don't rely on fixed condition order. [-Wcondition-order]
/* Generated by re2c */
#line 1 "condition_11.cg.re"
re2c: warning: line 3: rule matches empty string [-Wmatch-empty-string]
re2c: warning: line 9: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow]
re2c: warning: line 9: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 9: looks like you use hardcoded numbers instead of autogenerated condition names: better add '/*!types:re2c*/' directive or '-t, --type-header' option and don't rely on fixed condition order. [-Wcondition-order]
/* Generated by re2c */
#line 1 "condition_13.cg.re"
-re2c: warning: line 11: control flow in condition 'a' is undefined for strings that match '[\x0-\x60\x62-\xFF]', use default rule '*' [-Wundefined-control-flow]
-re2c: warning: line 11: control flow in condition 'b' is undefined for strings that match '[\x0-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 28: looks like you use hardcoded numbers instead of autogenerated condition names: better add '/*!types:re2c*/' directive or '-t, --type-header' option and don't rely on fixed condition order. [-Wcondition-order]
/* Generated by re2c */
#line 1 "condtype_yysetcondition.cg.re"
+#include <stdio.h>
+
+// changing this to '#if 1' changes program behaviour
+#if 0
+# define yyca 1
+# define yycb 0
+#else
+# define yyca 0
+# define yycb 1
+#endif
+
int main ()
{
- YYCONDTYPE cond;
- char * YYCURSOR;
+ int cond = yyca;
+ char * YYCURSOR = "aaaaaaaabb";
+#define YYSETCONDITION(c) cond = c
#define YYGETCONDITION() cond
+ for (;;)
+ {
-#line 10 "<stdout>"
+#line 24 "<stdout>"
{
unsigned char yych;
static void *yyctable[2] = {
- &&yyc_a,
&&yyc_b,
+ &&yyc_a,
};
goto *yyctable[YYGETCONDITION()];
/* *********************************** */
yyc_a:
yych = *YYCURSOR;
- if (yych == 'a') goto yy4;
-yy4:
+ if (yych != 'a') goto yy5;
+ ++YYCURSOR;
+#line 26 "condtype_yysetcondition.cg.re"
+ { printf ("a\n"); continue; }
+#line 39 "<stdout>"
+yy5:
++YYCURSOR;
YYSETCONDITION(yycb);
-#line 9 "condtype_yysetcondition.cg.re"
- {}
-#line 27 "<stdout>"
+#line 27 "condtype_yysetcondition.cg.re"
+ { printf ("a => b\n"); continue; }
+#line 45 "<stdout>"
/* *********************************** */
yyc_b:
yych = *YYCURSOR;
- if (yych == 'b') goto yy9;
-yy9:
++YYCURSOR;
-#line 10 "condtype_yysetcondition.cg.re"
- {}
-#line 36 "<stdout>"
+#line 24 "condtype_yysetcondition.cg.re"
+ { printf ("b\n"); break; }
+#line 52 "<stdout>"
}
-#line 11 "condtype_yysetcondition.cg.re"
+#line 28 "condtype_yysetcondition.cg.re"
+ }
return 0;
}
+#include <stdio.h>
+
+// changing this to '#if 1' changes program behaviour
+#if 0
+# define yyca 1
+# define yycb 0
+#else
+# define yyca 0
+# define yycb 1
+#endif
+
int main ()
{
- YYCONDTYPE cond;
- char * YYCURSOR;
+ int cond = yyca;
+ char * YYCURSOR = "aaaaaaaabb";
+#define YYSETCONDITION(c) cond = c
#define YYGETCONDITION() cond
+ for (;;)
+ {
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = "unsigned char";
- <a> "a" => b {}
- <b> "b" {}
+
+ <b> [^] { printf ("b\n"); break; }
+
+ <a> "a" { printf ("a\n"); continue; }
+ <a> [^a] => b { printf ("a => b\n"); continue; }
*/
+ }
return 0;
}
-re2c: warning: line 11: control flow in condition 'a' is undefined for strings that match '[\x0-\x60\x62-\xFF]', use default rule '*' [-Wundefined-control-flow]
-re2c: warning: line 11: control flow in condition 'b' is undefined for strings that match '[\x0-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 28: looks like you use hardcoded numbers instead of autogenerated condition names: better add '/*!types:re2c*/' directive or '-t, --type-header' option and don't rely on fixed condition order. [-Wcondition-order]
/* Generated by re2c */
#line 1 "condtype_yysetcondition.cs.re"
+#include <stdio.h>
+
+// changing this to '#if 1' changes program behaviour
+#if 0
+# define yyca 1
+# define yycb 0
+#else
+# define yyca 0
+# define yycb 1
+#endif
+
int main ()
{
- YYCONDTYPE cond;
- char * YYCURSOR;
+ int cond = yyca;
+ char * YYCURSOR = "aaaaaaaabb";
+#define YYSETCONDITION(c) cond = c
#define YYGETCONDITION() cond
+ for (;;)
+ {
-#line 10 "<stdout>"
+#line 24 "<stdout>"
{
unsigned char yych;
if (YYGETCONDITION() < 1) {
- goto yyc_a;
- } else {
goto yyc_b;
+ } else {
+ goto yyc_a;
}
/* *********************************** */
yyc_a:
yych = *YYCURSOR;
- if (yych == 'a') goto yy4;
-yy4:
+ if (yych != 'a') goto yy5;
+ ++YYCURSOR;
+#line 26 "condtype_yysetcondition.cs.re"
+ { printf ("a\n"); continue; }
+#line 39 "<stdout>"
+yy5:
++YYCURSOR;
YYSETCONDITION(yycb);
-#line 9 "condtype_yysetcondition.cs.re"
- {}
-#line 27 "<stdout>"
+#line 27 "condtype_yysetcondition.cs.re"
+ { printf ("a => b\n"); continue; }
+#line 45 "<stdout>"
/* *********************************** */
yyc_b:
yych = *YYCURSOR;
- if (yych == 'b') goto yy9;
-yy9:
++YYCURSOR;
-#line 10 "condtype_yysetcondition.cs.re"
- {}
-#line 36 "<stdout>"
+#line 24 "condtype_yysetcondition.cs.re"
+ { printf ("b\n"); break; }
+#line 52 "<stdout>"
}
-#line 11 "condtype_yysetcondition.cs.re"
+#line 28 "condtype_yysetcondition.cs.re"
+ }
return 0;
}
+#include <stdio.h>
+
+// changing this to '#if 1' changes program behaviour
+#if 0
+# define yyca 1
+# define yycb 0
+#else
+# define yyca 0
+# define yycb 1
+#endif
+
int main ()
{
- YYCONDTYPE cond;
- char * YYCURSOR;
+ int cond = yyca;
+ char * YYCURSOR = "aaaaaaaabb";
+#define YYSETCONDITION(c) cond = c
#define YYGETCONDITION() cond
+ for (;;)
+ {
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = "unsigned char";
- <a> "a" => b {}
- <b> "b" {}
+
+ <b> [^] { printf ("b\n"); break; }
+
+ <a> "a" { printf ("a\n"); continue; }
+ <a> [^a] => b { printf ("a => b\n"); continue; }
*/
+ }
return 0;
}
+re2c: warning: line 340: looks like you use hardcoded numbers instead of autogenerated condition names: better add '/*!types:re2c*/' directive or '-t, --type-header' option and don't rely on fixed condition order. [-Wcondition-order]
/* Generated by re2c */
/*
+----------------------------------------------------------------------+