Version 0.11.2 (????-??-??)
---------------------------
-- Add inplace configuration 're2c:yych:conversion'.
+- Added inplace configuration 're2c:yyfill:parameter'.
+- Added inplace configuration 're2c:yych:conversion'.
- Fixed -u switch code generation.
- Added ability to avoid defines and overwrite variable and label names.
{
if (n == 1)
{
- o << indent(ind) << "if(" << mapCodeName["YYLIMIT"] << " == " << mapCodeName["YYCURSOR"] << ") " << mapCodeName["YYFILL"] << "(1);\n";
+ o << indent(ind) << "if(" << mapCodeName["YYLIMIT"] << " == " << mapCodeName["YYCURSOR"] << ") " << mapCodeName["YYFILL"];
}
else
{
- o << indent(ind) << "if((" << mapCodeName["YYLIMIT"] << " - " << mapCodeName["YYCURSOR"] << ") < " << n << ") " << mapCodeName["YYFILL"] << "(" << n << ");\n";
+ o << indent(ind) << "if((" << mapCodeName["YYLIMIT"] << " - " << mapCodeName["YYCURSOR"] << ") < " << n << ") " << mapCodeName["YYFILL"];
}
+ if (bUseYYFillParam)
+ {
+ o << "(" << n << ")";
+ }
+ o << ";\n";
}
if (fFlag)
{
bUseYYFill = num != 0;
}
+ else if (cfg.to_string() == "yyfill:parameter")
+ {
+ bUseYYFillParam = num != 0;
+ }
else if (cfg.to_string() == "cgoto:threshold")
{
cGotoThreshold = num;
extern bool bUseStateNext;
extern bool bWroteGetState;
extern bool bUseYYFill;
+extern bool bUseYYFillParam;
extern uint asc2ebc[256];
extern uint ebc2asc[256];
<dd>Set this to zero to suppress generation of YYFILL(n). When using this be sure
to verify that the generated scanner does not read behind input. Allowing
this behavior might introduce sever security issues to you programs.</dd>
+<dt><i>re2c:yyfill:parameter</i> <b>=</b> 1 <b>;</b></dt>
+<dd>Allows to suppress parameter passing to <b>YYFILL</b> calls. If set to zero
+then no parameter is passed to <b>YYFILL</b>. If set to a non zero value then
+<b>YYFILL</b> usage will be followed by the number of requested characters in
+braces.</dd>
<dt><i>re2c:startlabel</i> <b>=</b> 0 <b>;</b></dt>
<dd>If set to a non zero integer then the start label of the next scanner
blocks will be generated even if not used by the scanner itself. Otherwise the
generation of jump tables rather than using nested if's and decision bitfields.
The threshold is compared against a calculated estimation of if-s needed where
every used bitmap divides the threshold by 2.</dd>
-.TP
<dt><i>re2c:yych:conversion</i> <b>=</b> 0 <b>;</b></dt>
<dd>When the input uses signed characters and <b>-s</b> or <b>-b</b> switches are
in effect re2c allows to automatically convert to the unsigned character type
bool bUsedYYMaxFill = false;
bool bUsedYYMarker = true;
-bool bUseStartLabel= false;
-bool bUseStateNext = false;
-bool bUseYYFill = true;
+bool bUseStartLabel = false;
+bool bUseStateNext = false;
+bool bUseYYFill = true;
+bool bUseYYFillParam = true;
std::string startLabelName;
std::string labelPrefix("yy");
to verify that the generated scanner does not read behind input. Allowing
this behavior might introduce sever security issues to you programs.
.TP
+\fIre2c:yyfill:parameter\fP \fB=\fP 1 \fB;\fP
+Allows to suppress parameter passing to \fBYYFILL\fP calls. If set to zero
+then no parameter is passed to \fBYYFILL\fP. If set to a non zero value then
+\fBYYFILL\fP usage will be followed by the number of requested characters in
+braces.
+.TP
\fIre2c:startlabel\fP \fB=\fP 0 \fB;\fP
If set to a non zero integer then the start label of the next scanner blocks
will be generated even if not used by the scanner itself. Otherwise the normal
--- /dev/null
+/* Generated by re2c */
+#line 1 "config10.re"
+#include <cstring>
+#include <iostream>
+
+struct Scanner
+{
+ Scanner(char *txt)
+ : cur(txt), lim(txt + strlen(txt))
+ {
+ }
+
+ char *cur;
+ char *lim;
+ char *ptr;
+ char *ctx;
+ char *tok;
+};
+
+enum What
+{
+ UNEXPECTED,
+ KEYWORD,
+ NUMBER,
+ EOI
+};
+
+char * tokens[] = { "UNEXPECTED", "KEYWORD", "NUMBER", "EOI" };
+
+void fill()
+{
+}
+
+int scan(Scanner &s)
+{
+ char *cursor = s.cur;
+
+ if(cursor == s.lim)
+ return EOI;
+
+std:
+ s.tok = cursor;
+
+
+#line 46 "<stdout>"
+{
+ char curr;
+
+ if((s.lim - s.cur) < 3) fill();
+ curr = *s.cur;
+ switch(curr) {
+ case 0x09:
+ case ' ': goto xx6;
+ case 0x0A: goto xx8;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto xx4;
+ case 'a':
+ case 'b': goto xx2;
+ default: goto xx9;
+ }
+xx2:
+ s.ctx = s.cur + 1;
+ ++s.cur;
+ switch((curr = *s.cur)) {
+ case '0':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto xx12;
+ case '1': goto xx15;
+ default: goto xx3;
+ }
+xx3:
+#line 67 "config10.re"
+ {
+ return UNEXPECTED;
+ }
+#line 91 "<stdout>"
+xx4:
+ ++s.cur;
+ curr = *s.cur;
+ goto xx11;
+xx5:
+#line 57 "config10.re"
+ { return NUMBER; }
+#line 99 "<stdout>"
+xx6:
+ ++s.cur;
+xx7:
+#line 60 "config10.re"
+ {
+ if(s.cur == s.lim)
+ return EOI;
+ cursor = s.cur;
+ goto std;
+ }
+#line 110 "<stdout>"
+xx8:
+ curr = *++s.cur;
+ goto xx7;
+xx9:
+ curr = *++s.cur;
+ goto xx3;
+xx10:
+ ++s.cur;
+ if(s.lim == s.cur) fill();
+ curr = *s.cur;
+xx11:
+ switch(curr) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto xx10;
+ default: goto xx5;
+ }
+xx12:
+ ++s.cur;
+ if(s.lim == s.cur) fill();
+ curr = *s.cur;
+ switch(curr) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto xx12;
+ default: goto xx14;
+ }
+xx14:
+ s.cur = s.ctx;
+#line 56 "config10.re"
+ { return KEYWORD; }
+#line 156 "<stdout>"
+xx15:
+ ++s.cur;
+ switch((curr = *s.cur)) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto xx12;
+ default: goto xx16;
+ }
+xx16:
+ s.cur = s.ctx;
+#line 55 "config10.re"
+ { return KEYWORD; }
+#line 176 "<stdout>"
+}
+#line 70 "config10.re"
+
+}
+
+int main(int,char**)
+{
+ Scanner s("a77 a1 b8 b1");
+
+ int t, n = 0;
+ while ((t = scan(s)) != EOI)
+ {
+ std::cout << (++n) << ": " << tokens[t] << " = \""; std::cout.write(s.tok, s.cur-s.tok); std::cout << "\"" << std::endl;
+ }
+}
--- /dev/null
+#include <cstring>
+#include <iostream>
+
+struct Scanner
+{
+ Scanner(char *txt)
+ : cur(txt), lim(txt + strlen(txt))
+ {
+ }
+
+ char *cur;
+ char *lim;
+ char *ptr;
+ char *ctx;
+ char *tok;
+};
+
+enum What
+{
+ UNEXPECTED,
+ KEYWORD,
+ NUMBER,
+ EOI
+};
+
+char * tokens[] = { "UNEXPECTED", "KEYWORD", "NUMBER", "EOI" };
+
+void fill()
+{
+}
+
+int scan(Scanner &s)
+{
+ char *cursor = s.cur;
+
+ if(cursor == s.lim)
+ return EOI;
+
+std:
+ s.tok = cursor;
+
+/*!re2c
+
+re2c:define:YYCTYPE = char;
+re2c:define:YYCURSOR = s.cur;
+re2c:define:YYLIMIT = s.lim;
+re2c:define:YYMARKER = s.ptr;
+re2c:define:YYCTXMARKER = s.ctx;
+re2c:define:YYFILL = "fill()";
+
+re2c:yyfill:parameter = 0;
+re2c:variable:yych = curr;
+re2c:labelprefix = xx;
+
+("a"|"b")/[1] { return KEYWORD; }
+("a"|"b")/[0-9]+ { return KEYWORD; }
+[0-9]+ { return NUMBER; }
+
+[ \t\n]
+ {
+ if(s.cur == s.lim)
+ return EOI;
+ cursor = s.cur;
+ goto std;
+ }
+.
+ {
+ return UNEXPECTED;
+ }
+*/
+}
+
+int main(int,char**)
+{
+ Scanner s("a77 a1 b8 b1");
+
+ int t, n = 0;
+ while ((t = scan(s)) != EOI)
+ {
+ std::cout << (++n) << ": " << tokens[t] << " = \""; std::cout.write(s.tok, s.cur-s.tok); std::cout << "\"" << std::endl;
+ }
+}