--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=us-ascii" />
+<title>re2c Home</title>
+</head>
+<body>
+<h1>re2c</h1>
+<b>re2c</b> is a great tool and has been unmaintained for quite some time,
+and in fact doesn't even compile with recent versions of gcc. I've used
+re2c in a few of my projects (e.g. OpenWBEM), and I have an interest in lexers
+(I wrote a dynamic lexer called slex as an example for the Spirit parser
+framework (see <a href="http://spirit.sf.net/">http://spirit.sf.net/</a>)).
+I didn't want to see it suffer bit-rot as there are a few bugs which need to be
+fixed as well as some new features that would be nice to add. So, after
+trying to contact either Peter Bumbulis or Brian Young, I decided to adopt the
+project and use SourceForge.net to host it.<br />
+<br />
+I very much welcome anyone who would like to contribute to the project, either
+as a developer with CVS access or by simply sending patches, bug reports, or
+suggestions for improvement. I have created a mailing list: re2c-general
+at lists dot sourceforge dot net which should be used for all communication
+about re2c.<br />
+<br />
+Please use the <a href="http://sourceforge.net/projects/re2c">SourceForge
+facilities</a> to download re2c, report bugs, subscribe to the mailing list,
+etc.<br />
+<br />
+You can view the manual online <a href="manual.html">here</a>.<br />
+<br />
+Dan Nuffer (nuffer@users.sourceforge.net)<br />
+<br />
+re2c is hosted at<br />
+<a href="http://sourceforge.net"><img src=
+"http://sourceforge.net/sflogo.php?group_id=72099&type=5" width="210"
+height="62" border="0" alt="SourceForge.net" /></a><br />
+<br />
+Other re2c links:
+<ul>
+<li>yasm is a tool which uses re2c, they created a C version and did some good
+fixes which I incorporated. <a href=
+"http://cvs.tortall.net/cgi-bin/viewcvs.cgi/yasm/tools/re2c/">http://cvs.tortall.net/cgi-bin/viewcvs.cgi/yasm/tools/re2c/</a></li>
+<li>FreeBSD page on the re2c ports package. <a href=
+"http://www.freshports.org/devel/re2c/">http://www.freshports.org/devel/re2c/</a></li>
+<li>Paper on re2c. <a href=
+"http://citeseer.nj.nec.com/cowan94rec.html">http://citeseer.nj.nec.com/cowan94rec.html</a></li>
+<li>Also the <a href="http://debian.org">debian</a> and <a href=
+"http://gentoo.org">Gentoo</a> Linux distributions have a package of re2c.</li>
+</ul>
+<hr />
+<h1>Changelog</h1>
+<h2>2005-06-26: 0.9.8 released</h2>
+<ul>
+<li>Fixed code generation for -b switch. </li>
+</ul>
+<h2>2005-04-30: 0.9.7 released</h2>
+<ul>
+<li>Applied #1181535 storable state patch.</li>
+<li>Added -d flag which outputs a debugable parser.</li>
+<li>Fixed generation of '#line' directives (according to ISO-C99).</li>
+<li>Fixed bug #1187785 Re2c fails to generate valid code.</li>
+<li>Fixed bug #1187452 unused variable `yyaccept'.</li>
+</ul>
+<h2>2005-04-14: 0.9.6 released</h2>
+<ul>
+<li>Fix build with gcc >= 3.4.</li>
+</ul>
+<h2>2005-04-08: 0.9.5 released</h2>
+<ul>
+<li>Added /*!max:re2c */ which emits a '#define YYMAXFILL <max>\n' line
+This allows to define buffers of the minimum required length. Occurence must
+follow '/*re2c */ and cannot preceed it.</li>
+<li>Changed re2c to two pass generation to output warning free code.</li>
+<li>Fixed bug #1163046 re2c hangs when processing valid re-file.</li>
+<li>Fixed bug #1022799 re2c scanner has buffering bug.</li>
+</ul>
+<h2>2005-03-12: 0.9.4 released</h2>
+<ul>
+<li>Added --vernum support.</li>
+<li>Fixed bug #1054496 incorrect code generated with -b option.</li>
+<li>Fixed bug #1012748 re2c does not emit last line if '\n' missing.</li>
+<li>Fixed bug #999104 --output=output option does not work as documented.</li>
+<li>Fixed bug #999103 Invalid options prefixed with two dashes cause program
+crash.</li>
+</ul>
+<h2>2004-05-26: 0.9.3 released</h2>
+<ul>
+<li>Fixes one small possible bug in the generated output. ych instead of yych
+is output in certain circumstances</li>
+</ul>
+<h2>2004-05-26: 0.9.3 released</h2>
+<ul>
+<li>Fixes one small possible bug in the generated output. ych instead of yych
+is output in certain circumstances.</li>
+</ul>
+<h2>2004-05-26: 0.9.2 released</h2>
+<ul>
+<li>Added -o option to specify the output file which also will set the #line
+directives to something useful.</li>
+<li>Print version to cout instead cerr.</li>
+<li>Added -h and -- style options.</li>
+<li>Moved development to <a href=
+"http://sourceforge.net/projects/re2c">http://sourceforge.net/projects/re2c</a></li>
+<li>Fixed bug #960144 minor cosmetic problem.</li>
+<li>Fixed bug #953181 cannot compile with.</li>
+<li>Fixed bug #939277 Windows support.</li>
+<li>Fixed bug #914462 automake build patch</li>
+<li>Fixed bug #891940 braced quantifiers: {\d+(,|,\d+)?} style.</li>
+<li>Fixed bug #869298 Add case insensitive string literals.</li>
+<li>Fixed bug #869297 Input buffer overrun.</li>
+</ul>
+<h2>2003-12-13: 0.9.1 release</h2>
+<ul>
+<li>Removed rcs comments in source files.</li>
+</ul>
+<h2>2003-12-09: re2c adopted</h2>
+<hr />
+<h2>Version 0.9.1 README</h2>
+<br />
+Originally written by Peter Bumbulis (peter@csg.uwaterloo.ca)<br />
+Currently maintained by Brian Young (bayoung@acm.org)<br />
+<br />
+The re2c distribution can be found at:<br />
+<br />
+http://www.tildeslash.org/re2c/index.html<br />
+<br />
+The source distribution is available from:<br />
+<br />
+http://www.tildeslash.org/re2c/re2c-0.9.1.tar.gz<br />
+<br />
+This distribution is a cleaned up version of the 0.5 release<br />
+maintained by me (Brian Young). Several bugs were fixed as well<br />
+as code cleanup for warning free compilation. It has been developed<br />
+and tested with egcs 1.0.2 and gcc 2.7.2.3 on Linux x86. Peter<br />
+Bumbulis' original release can be found at:<br />
+<br />
+ftp://csg.uwaterloo.ca/pub/peter/re2c.0.5.tar.gz<br />
+<br />
+re2c is a great tool for writing fast and flexible lexers. It has<br />
+served many people well for many years and it deserves to be<br />
+maintained more actively. re2c is on the order of 2-3 times faster<br />
+than a flex based scanner, and its input model is much more<br />
+flexible.<br />
+<br />
+Patches and requests for features will be entertained. Areas of<br />
+particular interest to me are porting (a Solaris and an NT<br />
+version will be forthcoming) and wide character support. Note<br />
+that the code is already quite portable and should be buildable<br />
+on any platform with minor makefile changes.<br />
+<hr />
+<h2>Version 0.5 <b>Peter's</b> original ANNOUNCE and README</h2>
+re2c is a tool for generating C-based recognizers from regular<br />
+expressions. re2c-based scanners are efficient: for programming<br />
+languages, given similar specifications, an re2c-based scanner is<br />
+typically almost twice as fast as a flex-based scanner with little or no<br />
+increase in size (possibly a decrease on cisc architectures). Indeed,<br />
+re2c-based scanners are quite competitive with hand-crafted ones.<br />
+<br />
+Unlike flex, re2c does not generate complete scanners: the user must<br />
+supply some interface code. While this code is not bulky (about 50-100<br />
+lines for a flex-like scanner; see the man page and examples in the<br />
+distribution) careful coding is required for efficiency (and<br />
+correctness). One advantage of this arrangement is that the generated<br />
+code is not tied to any particular input model. For example, re2c<br />
+generated code can be used to scan data from a null-byte terminated<br />
+buffer as illustrated below.<br />
+<br />
+Given the following source<br />
+<br />
+#define NULL ((char*) 0)<br />
+char *scan(char *p){<br />
+char *q;<br />
+#define YYCTYPE char<br />
+#define YYCURSOR p<br />
+#define YYLIMIT p<br />
+#define YYMARKER q<br />
+#define YYFILL(n)<br />
+/*!re2c<br />
+[0-9]+ {return YYCURSOR;}<br />
+[\000-\377] {return NULL;}<br />
+*/<br />
+}<br />
+<br />
+re2c will generate<br />
+<br />
+/* Generated by re2c on Sat Apr 16 11:40:58 1994 */<br />
+#line 1 "simple.re"<br />
+#define NULL ((char*) 0)<br />
+char *scan(char *p){<br />
+char *q;<br />
+#define YYCTYPE char<br />
+#define YYCURSOR p<br />
+#define YYLIMIT p<br />
+#define YYMARKER q<br />
+#define YYFILL(n)<br />
+{<br />
+YYCTYPE yych;<br />
+unsigned int yyaccept;<br />
+goto yy0;<br />
+yy1: ++YYCURSOR;<br />
+yy0:<br />
+if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);<br />
+yych = *YYCURSOR;<br />
+if(yych <= '/') goto yy4;<br />
+if(yych >= ':') goto yy4;<br />
+yy2: yych = *++YYCURSOR;<br />
+goto yy7;<br />
+yy3:<br />
+#line 10<br />
+{return YYCURSOR;}<br />
+yy4: yych = *++YYCURSOR;<br />
+yy5:<br />
+#line 11<br />
+{return NULL;}<br />
+yy6: ++YYCURSOR;<br />
+if(YYLIMIT == YYCURSOR) YYFILL(1);<br />
+yych = *YYCURSOR;<br />
+yy7: if(yych <= '/') goto yy3;<br />
+if(yych <= '9') goto yy6;<br />
+goto yy3;<br />
+}<br />
+#line 12<br />
+<br />
+}<br />
+<br />
+Note that most compilers will perform dead-code elimination to remove<br />
+all YYCURSOR, YYLIMIT comparisions.<br />
+<br />
+re2c was developed for a particular project (constructing a fast REXX<br />
+scanner of all things!) and so while it has some rough edges, it should<br />
+be quite usable. More information about re2c can be found in the<br />
+(admittedly skimpy) man page; the algorithms and heuristics used are<br />
+described in an upcoming LOPLAS article (included in the distribution).<br />
+Probably the best way to find out more about re2c is to try the supplied<br />
+examples. re2c is written in C++, and is currently being developed<br />
+under Linux using gcc 2.5.8.<br />
+<br />
+Peter<br />
+<br />
+--<br />
+<br />
+re2c is distributed with no warranty whatever. The code is certain to<br />
+contain errors. Neither the author nor any contributor takes<br />
+responsibility for any consequences of its use.<br />
+<br />
+re2c is in the public domain. The data structures and algorithms used<br />
+in re2c are all either taken from documents available to the general<br />
+public or are inventions of the author. Programs generated by re2c may<br />
+be distributed freely. re2c itself may be distributed freely, in source<br />
+or binary, unchanged or modified. Distributors may charge whatever fees<br />
+they can obtain for re2c.<br />
+<br />
+If you do make use of re2c, or incorporate it into a larger project an<br />
+acknowledgement somewhere (documentation, research report, etc.) would<br />
+be appreciated.<br />
+<br />
+Please send bug reports and feedback (including suggestions for<br />
+improving the distribution) to<br />
+<br />
+Include a small example and the banner from parser.y with bug reports.<br />
+<br />
+peter@csg.uwaterloo.ca<br />
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Manpage of RE2C</title>
+</head>
+<body>
+<h1>RE2C</h1>
+Section: User Commands (1)<br />
+Updated: 26 June 2005<br />
+<a href="#index">Index</a>
+<hr />
+<a name="lbAB" id="lbAB"> </a>
+<h2>NAME</h2>
+<p>re2c - convert regular expressions to C/C++</p>
+<a name="lbAC" id="lbAC"> </a>
+<h2>SYNOPSIS</h2>
+<p><b>re2c</b> [<b>-efsbvhd</b>] [<b>-o output</b>] file</p>
+<a name="lbAD" id="lbAD"> </a>
+<h2>DESCRIPTION</h2>
+<p><b>re2c</b> is a preprocessor that generates C-based recognizers from
+regular expressions. The input to <b>re2c</b> consists of C/C++ source
+interleaved with comments of the form /*!re2c ... */ which contain scanner
+specifications. In the output these comments are replaced with code that, when
+executed, will find the next input token and then execute some user-supplied
+token-specific code.</p>
+<p>For example, given the following code</p>
+<pre>
+#define NULL ((char*) 0)
+char *scan(char *p){
+char *q;
+#define YYCTYPE char
+#define YYCURSOR p
+#define YYLIMIT p
+#define YYMARKER q
+#define YYFILL(n)
+/*!re2c
+ [0-9]+ {return YYCURSOR;}
+ [\000-\377] {return NULL;}
+*/
+}
+</pre>
+<br />
+<br />
+<p><b>re2c</b> will generate</p>
+<pre>
+/* Generated by re2c on Sat Apr 16 11:40:58 1994 */
+#line 1 "simple.re"
+#define NULL ((char*) 0)
+char *scan(char *p){
+char *q;
+#define YYCTYPE char
+#define YYCURSOR p
+#define YYLIMIT p
+#define YYMARKER q
+#define YYFILL(n)
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy0;
+yy1: ++YYCURSOR;
+yy0:
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ if(yych <= '/') goto yy4;
+ if(yych >= ':') goto yy4;
+yy2: yych = *++YYCURSOR;
+ goto yy7;
+yy3:
+#line 10
+ {return YYCURSOR;}
+yy4: yych = *++YYCURSOR;
+yy5:
+#line 11
+ {return NULL;}
+yy6: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+yy7: if(yych <= '/') goto yy3;
+ if(yych <= '9') goto yy6;
+ goto yy3;
+}
+#line 12
+
+}
+</pre>
+<br />
+<br />
+<p>After the /*!re2c */ blocks you can place a /*!max:re2c */ block that will
+output a define that holds the maximum number of characters required to parse
+the input. That is the maximum value YYFILL() will receive.</p>
+<a name="lbAE" id="lbAE"> </a>
+<h2>OPTIONS</h2>
+<p><b>re2c</b> provides the following options:</p>
+<dl compact="compact">
+<dt><b>-e</b></dt>
+<dd>Cross-compile from an ASCII platform to an EBCDIC one.<br /><br /></dd>
+<dt><b>-f</b></dt>
+<dd>Generate a scanner with support for storable state.<br /><br /></dd>
+<dt><b>-s</b></dt>
+<dd>Generate nested ifs for some switches. Many compilers need this assist to
+generate better code.<br /><br /></dd>
+<dt><b>-b</b></dt>
+<dd>Implies <b>-s</b>. Use bit vectors as well in the attempt to coax better
+code out of the compiler. Most useful for specifications with more than a few
+keywords (e.g. for most programming languages).<br /><br /></dd>
+<dt><b>-d</b></dt>
+<dd>Creates a parser that dumps information about the current position and in
+which state the parser is while parsing the input. This is useful to debug
+parser issues and states. If you use this switch you need to define a macro
+<i>YYDEBUG</i> that is called like a function with two parameters: <i>void
+YYDEBUG(int state, char current)</i>. The first parameter receives the state or
+-1 and the second parameter receives the input at the current cursor.<br /><br /></dd>
+<dt><b>-h</b></dt>
+<dd><b>-?</b> Invoke a short help.<br /><br /></dd>
+<dt><b>-v</b></dt>
+<dd>Show version information.<br /><br /></dd>
+<dt><b>-V</b></dt>
+<dd>Show the version as a number XXYYZZ.<br /><br /></dd>
+<dt><b>-o output</b></dt>
+<dd>Specify the output file.<br /><br /></dd>
+</dl>
+<br />
+<br />
+<a name="lbAF" id="lbAF"> </a>
+<h2>INTERFACE CODE</h2>
+<p>Unlike other scanner generators, <b>re2c</b> does not generate complete
+scanners: the user must supply some interface code. In particular, the user
+must define the following macros:</p>
+<dl compact="compact">
+<dt>YYCTYPE</dt>
+<dd>Type used to hold an input symbol. Usually char or unsigned char.<br /><br /></dd>
+<dt>YYCURSOR</dt>
+<dd><i>l</i>-expression of type *YYCTYPE that points to the current input
+symbol. The generated code advances YYCURSOR as symbols are matched. On entry,
+YYCURSOR is assumed to point to the first character of the current token. On
+exit, YYCURSOR will point to the first character of the following token.<br /><br /></dd>
+<dt>YLIMIT</dt>
+<dd>Expression of type *YYCTYPE that marks the end of the buffer (YLIMIT[-1] is
+the last character in the buffer). The generated code repeatedly compares
+YYCURSOR to YLIMIT to determine when the buffer needs (re)filling.<br /><br /></dd>
+<dt>YYMARKER</dt>
+<dd><i>l</i>-expression of type *YYCTYPE. The generated code saves backtracking
+information in YYMARKER.<br /><br /></dd>
+<dt>YYFILL(<i>n</i>)</dt>
+<dd>The generated code "calls" YYFILL when the buffer needs (re)filling: at
+least <i>n</i> additional characters should be provided. YYFILL should adjust
+YYCURSOR, YYLIMIT and YYMARKER as needed. Note that for typical programming
+languages <i>n</i> will be the length of the longest keyword plus one.<br /><br /></dd>
+<dt>YYGETSTATE()</dt>
+<dd>The user only needs to define this macro if the <b>-f</b> flag was
+specified. In that case, the generated code "calls" YYGETSTATE at the very
+beginning of the scanner in order to obtain the saved state. YYGETSTATE must
+return a signed integer. The value must be either -1, indicating that the
+scanner is entered for the first time, or a value previously saved by
+YYSETSTATE. In the second case, the scanner will resume operations right after
+where the last YYFILL was called.<br /><br /></dd>
+<dt>YYSETSTATE(<i>n</i>)</dt>
+<dd>The user only needs to define this macro if the <b>-f</b> flag was
+specified. In that case, the generated code "calls" YYSETSTATE just before
+calling YYFILL. The parameter to YYSETSTATE is a signed integer that uniquely
+identifies the specific instance of YYFILL that is about to be called. Should
+the user wish to save the state of the scanner and have YYFILL return to the
+caller, all he has to do is store that unique identifer in a variable. Later,
+when the scannered is called again, it will call YYGETSTATE() and resume
+execution right where it left off.<br /><br /></dd>
+</dl>
+<br />
+<br />
+<a name="lbAG" id="lbAG"> </a>
+<h2>SCANNER WITH STORABLE STATES</h2>
+<p>When the <b>-f</b> flag is specified, re2c generates a scanner that can
+store its current state, return to the caller, and later resume operations
+exactly where it left off.</p>
+<p>The default operation of re2c is a "pull" model, where the scanner asks for
+extra input whenever it needs it. However, this mode of operation assumes that
+the scanner is the "owner" the parsing loop, and that may not always be
+convenient.</p>
+<p>Typically, if there is a preprocessor ahead of the scanner in the stream, or
+for that matter any other procedural source of data, the scanner cannot "ask"
+for more data unless both scanner and source live in a separate threads.</p>
+<p>The <b>-f</b> flag is useful for just this situation : it lets users design
+scanners that work in a "push" model, i.e. where data is fed to the scanner
+chunk by chunk. When the scanner runs out of data to consume, it just stores
+its state, and return to the caller. When more input data is fed to the
+scanner, it resumes operations exactly where it left off.</p>
+<p>At this point, the -f option only works with "mono-block" re2c scanners: if
+the scanner is described with more than one /*!re2c ... */ block, re2c -f fails
+with an error.</p>
+<p>Please see examples/push.re for push-model scanner.</p>
+<a name="lbAH" id="lbAH"> </a>
+<h2>SCANNER SPECIFICATIONS</h2>
+<p>Each scanner specification consists of a set of <i>rules</i> and name
+definitions. Rules consist of a regular expression along with a block of C/C++
+code that is to be executed when the associated regular expression is matched.
+Name definitions are of the form ``<i>name</i> = <i>regular
+expression</i>;''.</p>
+<a name="lbAI" id="lbAI"> </a>
+<h2>SUMMARY OF RE2C REGULAR EXPRESSIONS</h2>
+<dl compact="compact">
+<dt>"foo"</dt>
+<dd>the literal string foo. ANSI-C escape sequences can be used.</dd>
+<dt>'foo'</dt>
+<dd>the literal string foo (characters [a-zA-Z] treated case-insensitive).
+ANSI-C escape sequences can be used.</dd>
+<dt>[xyz]</dt>
+<dd>a "character class"; in this case, the regular expression matches either an
+'x', a 'y', or a 'z'.</dd>
+<dt>[abj-oZ]</dt>
+<dd>a "character class" with a range in it; matches an 'a', a 'b', any letter
+from 'j' through 'o', or a 'Z'.</dd>
+<dt><i>r</i>\<i>s</i></dt>
+<dd>match any <i>r</i> which isn't an <i>s</i>. <i>r</i> and <i>s</i> must be
+regular expressions which can be expressed as character classes.</dd>
+<dt><i>r</i>*</dt>
+<dd>zero or more <i>r</i>'s, where <i>r</i> is any regular expression</dd>
+<dt><i>r</i>+</dt>
+<dd>one or more <i>r</i>'s</dd>
+<dt><i>r</i>?</dt>
+<dd>zero or one <i>r</i>'s (that is, "an optional <i>r</i>")</dd>
+<dt>name</dt>
+<dd>the expansion of the "name" definition (see above)</dd>
+<dt>(<i>r</i>)</dt>
+<dd>an <i>r</i>; parentheses are used to override precedence (see below)</dd>
+<dt><i>rs</i></dt>
+<dd>an <i>r</i> followed by an <i>s</i> ("concatenation")</dd>
+<dt><i>r</i>|<i>s</i></dt>
+<dd>either an <i>r</i> or an <i>s</i></dd>
+<dt><i>r</i>/<i>s</i></dt>
+<dd>an <i>r</i> but only if it is followed by an <i>s</i>. The s is not part of
+the matched text. This type of regular expression is called "trailing
+context".</dd>
+<dt><i>r</i>{<i>n</i>}</dt>
+<dd>matches <i>r</i> exactly <i>n</i> times.</dd>
+<dt><i>r</i>{<i>n</i>,}</dt>
+<dd>matches <i>r</i> at least <i>n</i> times.</dd>
+<dt><i>r</i>{<i>n</i>,<i>m</i>}</dt>
+<dd>matches <i>r</i> at least <i>n</i> but not more than <i>m</i> times.</dd>
+</dl>
+<br />
+<br />
+<p>The regular expressions listed above are grouped according to precedence,
+from highest precedence at the top to lowest at the bottom. Those grouped
+together have equal precedence.</p>
+<a name="lbAJ" id="lbAJ"> </a>
+<h2>A LARGER EXAMPLE</h2>
+<pre>
+#include <<a href="file:/usr/include/stdlib.h">stdlib.h</a>>
+#include <<a href="file:/usr/include/stdio.h">stdio.h</a>>
+#include <<a href="file:/usr/include/fcntl.h">fcntl.h</a>>
+#include <<a href="file:/usr/include/string.h">string.h</a>>
+
+#define ADDEQ 257
+#define ANDAND 258
+#define ANDEQ 259
+#define ARRAY 260
+#define ASM 261
+#define AUTO 262
+#define BREAK 263
+#define CASE 264
+#define CHAR 265
+#define CONST 266
+#define CONTINUE 267
+#define DECR 268
+#define DEFAULT 269
+#define DEREF 270
+#define DIVEQ 271
+#define DO 272
+#define DOUBLE 273
+#define ELLIPSIS 274
+#define ELSE 275
+#define ENUM 276
+#define EQL 277
+#define EXTERN 278
+#define FCON 279
+#define FLOAT 280
+#define FOR 281
+#define FUNCTION 282
+#define GEQ 283
+#define GOTO 284
+#define ICON 285
+#define ID 286
+#define IF 287
+#define INCR 288
+#define INT 289
+#define LEQ 290
+#define LONG 291
+#define LSHIFT 292
+#define LSHIFTEQ 293
+#define MODEQ 294
+#define MULEQ 295
+#define NEQ 296
+#define OREQ 297
+#define OROR 298
+#define POINTER 299
+#define REGISTER 300
+#define RETURN 301
+#define RSHIFT 302
+#define RSHIFTEQ 303
+#define SCON 304
+#define SHORT 305
+#define SIGNED 306
+#define SIZEOF 307
+#define STATIC 308
+#define STRUCT 309
+#define SUBEQ 310
+#define SWITCH 311
+#define TYPEDEF 312
+#define UNION 313
+#define UNSIGNED 314
+#define VOID 315
+#define VOLATILE 316
+#define WHILE 317
+#define XOREQ 318
+#define EOI 319
+
+typedef unsigned int uint;
+typedef unsigned char uchar;
+
+#define BSIZE 8192
+
+#define YYCTYPE uchar
+#define YYCURSOR cursor
+#define YYLIMIT s->lim
+#define YYMARKER s->ptr
+#define YYFILL(n) {cursor = fill(s, cursor);}
+
+#define RET(i) {s->cur = cursor; return i;}
+
+typedef struct Scanner {
+ int fd;
+ uchar *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof;
+ uint line;
+} Scanner;
+
+uchar *fill(Scanner *s, uchar *cursor){
+ if(!s->eof){
+ uint cnt = s->tok - s->bot;
+ if(cnt){
+ memcpy(s->bot, s->tok, s->lim - s->tok);
+ s->tok = s->bot;
+ s->ptr -= cnt;
+ cursor -= cnt;
+ s->pos -= cnt;
+ s->lim -= cnt;
+ }
+ if((s->top - s->lim) < BSIZE){
+ uchar *buf = (uchar*)
+ malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar));
+ memcpy(buf, s->tok, s->lim - s->tok);
+ s->tok = buf;
+ s->ptr = &buf[s->ptr - s->bot];
+ cursor = &buf[cursor - s->bot];
+ s->pos = &buf[s->pos - s->bot];
+ s->lim = &buf[s->lim - s->bot];
+ s->top = &s->lim[BSIZE];
+ free(s->bot);
+ s->bot = buf;
+ }
+ if((cnt = read(s->fd, (char*) s->lim, BSIZE)) != BSIZE){
+ s->eof = &s->lim[cnt]; *(s->eof)++ = '\n';
+ }
+ s->lim += cnt;
+ }
+ s->cur = cursor;
+ return cursor;
+}
+
+int scan(Scanner *s){
+ uchar *cursor = s->cur;
+std:
+ s->tok = cursor;
+/*!re2c
+any = [\000-\377];
+O = [0-7];
+D = [0-9];
+L = [a-zA-Z_];
+H = [a-fA-F0-9];
+E = [Ee] [+-]? D+;
+FS = [fFlL];
+IS = [uUlL]*;
+ESC = [\\] ([abfnrtv?'"\\] | "x" H+ | O+);
+*/
+
+/*!re2c
+ "/*" { goto comment; }
+
+ "auto" { RET(AUTO); }
+ "break" { RET(BREAK); }
+ "case" { RET(CASE); }
+ "char" { RET(CHAR); }
+ "const" { RET(CONST); }
+ "continue" { RET(CONTINUE); }
+ "default" { RET(DEFAULT); }
+ "do" { RET(DO); }
+ "double" { RET(DOUBLE); }
+ "else" { RET(ELSE); }
+ "enum" { RET(ENUM); }
+ "extern" { RET(EXTERN); }
+ "float" { RET(FLOAT); }
+ "for" { RET(FOR); }
+ "goto" { RET(GOTO); }
+ "if" { RET(IF); }
+ "int" { RET(INT); }
+ "long" { RET(LONG); }
+ "register" { RET(REGISTER); }
+ "return" { RET(RETURN); }
+ "short" { RET(SHORT); }
+ "signed" { RET(SIGNED); }
+ "sizeof" { RET(SIZEOF); }
+ "static" { RET(STATIC); }
+ "struct" { RET(STRUCT); }
+ "switch" { RET(SWITCH); }
+ "typedef" { RET(TYPEDEF); }
+ "union" { RET(UNION); }
+ "unsigned" { RET(UNSIGNED); }
+ "void" { RET(VOID); }
+ "volatile" { RET(VOLATILE); }
+ "while" { RET(WHILE); }
+
+ L (L|D)* { RET(ID); }
+
+ ("0" [xX] H+ IS?) | ("0" D+ IS?) | (D+ IS?) |
+ (['] (ESC|any\[\n\\'])* ['])
+ { RET(ICON); }
+
+ (D+ E FS?) | (D* "." D+ E? FS?) | (D+ "." D* E? FS?)
+ { RET(FCON); }
+
+ (["] (ESC|any\[\n\\"])* ["])
+ { RET(SCON); }
+
+ "..." { RET(ELLIPSIS); }
+ ">>=" { RET(RSHIFTEQ); }
+ "<<=" { RET(LSHIFTEQ); }
+ "+=" { RET(ADDEQ); }
+ "-=" { RET(SUBEQ); }
+ "*=" { RET(MULEQ); }
+ "/=" { RET(DIVEQ); }
+ "%=" { RET(MODEQ); }
+ "&=" { RET(ANDEQ); }
+ "^=" { RET(XOREQ); }
+ "|=" { RET(OREQ); }
+ ">>" { RET(RSHIFT); }
+ "<<" { RET(LSHIFT); }
+ "++" { RET(INCR); }
+ "--" { RET(DECR); }
+ "->" { RET(DEREF); }
+ "&&" { RET(ANDAND); }
+ "||" { RET(OROR); }
+ "<=" { RET(LEQ); }
+ ">=" { RET(GEQ); }
+ "==" { RET(EQL); }
+ "!=" { RET(NEQ); }
+ ";" { RET(';'); }
+ "{" { RET('{'); }
+ "}" { RET('}'); }
+ "," { RET(','); }
+ ":" { RET(':'); }
+ "=" { RET('='); }
+ "(" { RET('('); }
+ ")" { RET(')'); }
+ "[" { RET('['); }
+ "]" { RET(']'); }
+ "." { RET('.'); }
+ "&" { RET('&'); }
+ "!" { RET('!'); }
+ "~" { RET('~'); }
+ "-" { RET('-'); }
+ "+" { RET('+'); }
+ "*" { RET('*'); }
+ "/" { RET('/'); }
+ "%" { RET('%'); }
+ "<" { RET('<'); }
+ ">" { RET('>'); }
+ "^" { RET('^'); }
+ "|" { RET('|'); }
+ "?" { RET('?'); }
+
+
+ [ \t\v\f]+ { goto std; }
+
+ "\n"
+ {
+ if(cursor == s->eof) RET(EOI);
+ s->pos = cursor; s->line++;
+ goto std;
+ }
+
+ any
+ {
+ printf("unexpected character: %c\n", *s->tok);
+ goto std;
+ }
+*/
+
+comment:
+/*!re2c
+ "*/" { goto std; }
+ "\n"
+ {
+ if(cursor == s->eof) RET(EOI);
+ s->tok = s->pos = cursor; s->line++;
+ goto comment;
+ }
+ any { goto comment; }
+*/
+}
+
+main(){
+ Scanner in;
+ int t;
+ memset((char*) &in, 0, sizeof(in));
+ in.fd = 0;
+ while((t = scan(&in)) != EOI){
+/*
+ printf("%d\t%.*s\n", t, in.cur - in.tok, in.tok);
+ printf("%d\n", t);
+*/
+ }
+ close(in.fd);
+}
+</pre>
+<br />
+<br />
+<a name="lbAK" id="lbAK"> </a>
+<h2>FEATURES</h2>
+<p><b>re2c</b> does not provide a default action: the generated code assumes
+that the input will consist of a sequence of tokens. Typically this can be
+dealt with by adding a rule such as the one for unexpected characters in the
+example above.</p>
+<p>The user must arrange for a sentinel token to appear at the end of input
+(and provide a rule for matching it): <b>re2c</b> does not provide an
+<<EOF>> expression. If the source is from a null-byte terminated
+string, a rule matching a null character will suffice. If the source is from a
+file then the approach taken in the example can be used: pad the input with a
+newline (or some other character that can't appear within another token); upon
+recognizing such a character check to see if it is the sentinel and act
+accordingly.</p>
+<p><b>re2c</b> does not provide start conditions: use a separate scanner
+specification for each start condition (as illustrated in the above
+example).</p>
+No [^x]. Use difference instead. <a name="lbAL" id="lbAL"> </a>
+<h2>BUGS</h2>
+<p>Only fixed length trailing context can be handled.</p>
+<p>Difference only works for character sets.</p>
+<p>The <b>re2c</b> internal algorithms need documentation.</p>
+<a name="lbAM" id="lbAM"> </a>
+<h2>SEE ALSO</h2>
+<p>flex(1), lex(1). More information on <b>re2c</b> can be found here:
+<b><a href=
+"http://sourceforge.net/projects/re2c/">http://sourceforge.net/projects/re2c/</a></b></p>
+<a name="lbAN" id="lbAN"> </a>
+<h2>AUTHORS</h2>
+<ul>
+<li>Peter Bumbulis <<a href=
+"mailto:peter@csg.uwaterloo.ca">peter@csg.uwaterloo.ca</a>></li>
+<li>Brian Young <<a href=
+"mailto:bayoung@acm.org">bayoung@acm.org</a>></li>
+<li>Dan Nuffer <<a href=
+"mailto:nuffer@users.sourceforge.net">nuffer@users.sourceforge.net</a>></li>
+<li>Marcus Boerger <<a href=
+"mailto:helly@users.sourceforge.net">helly@users.sourceforge.net</a>></li>
+<li>Hartmut Kaiser <<a href=
+"mailto:hkaiser@users.sourceforge.net">hkaiser@users.sourceforge.net</a>></li>
+<li>Emmanuel Mogenet <<a href="mailto:mgix@mgix.com">mgix@mgix.com</a>>
+(added storable state)</li>
+</ul>
+<br />
+<br />
+<a name="lbAO" id="lbAO"> </a>
+<h2>VERSION INFORMATION</h2>
+<p>This manpage describes <b>re2c</b>, version 0.9.8.</p>
+<hr />
+<a name="index" id="index"> </a>
+<h2>Index</h2>
+<dl>
+<dt><a href="#lbAB">NAME</a><br /></dt>
+<dt><a href="#lbAC">SYNOPSIS</a><br /></dt>
+<dt><a href="#lbAD">DESCRIPTION</a><br /></dt>
+<dt><a href="#lbAE">OPTIONS</a><br /></dt>
+<dt><a href="#lbAF">INTERFACE CODE</a><br /></dt>
+<dt><a href="#lbAG">SCANNER WITH STORABLE STATES</a><br /></dt>
+<dt><a href="#lbAH">SCANNER SPECIFICATIONS</a><br /></dt>
+<dt><a href="#lbAI">SUMMARY OF RE2C REGULAR EXPRESSIONS</a><br /></dt>
+<dt><a href="#lbAJ">A LARGER EXAMPLE</a><br /></dt>
+<dt><a href="#lbAK">FEATURES</a><br /></dt>
+<dt><a href="#lbAL">BUGS</a><br /></dt>
+<dt><a href="#lbAM">SEE ALSO</a><br /></dt>
+<dt><a href="#lbAN">AUTHORS</a><br /></dt>
+<dt><a href="#lbAO">VERSION INFORMATION</a><br /></dt>
+</dl>
+<br />
+<br />
+<hr />
+<p>This document was created by man2html, using the manual pages.<br />
+Time: 10:30:42 GMT, June 26, 2005</p>
+</body>
+</html>