version 1.9, 2001/08/21 00:56:18 |
version 1.10, 2003/01/01 21:11:01 |
|
|
Deficiencies / Bugs section below regarding |
Deficiencies / Bugs section below regarding |
"dangerous trailing context".) |
"dangerous trailing context".) |
^r an r, but only at the beginning of a line (i.e., |
^r an r, but only at the beginning of a line (i.e., |
which just starting to scan, or right after a |
just starting to scan, or right after a |
newline has been scanned). |
newline has been scanned). |
r$ an r, but only at the end of a line (i.e., just |
r$ an r, but only at the end of a line (i.e., just |
before a newline). Equivalent to "r/\\n". |
before a newline). Equivalent to "r/\\n". |
|
|
.B yytext |
.B yytext |
(see the next section), and calls to the |
(see the next section), and calls to the |
.B unput() |
.B unput() |
function destroys the present contents of |
function destroy the present contents of |
.B yytext, |
.B yytext, |
which can be a considerable porting headache when moving between different |
which can be a considerable porting headache when moving between different |
.I lex |
.I lex |
|
|
while in the first example it's active in both, because in the first |
while in the first example it's active in both, because in the first |
example the |
example the |
.B example |
.B example |
startion condition is an |
start condition is an |
.I inclusive |
.I inclusive |
.B (%s) |
.B (%s) |
start condition. |
start condition. |
|
|
.fi |
.fi |
This scanner goes to a bit of trouble to match as much |
This scanner goes to a bit of trouble to match as much |
text as possible with each rule. In general, when attempting to write |
text as possible with each rule. In general, when attempting to write |
a high-speed scanner try to match as much possible in each rule, as |
a high-speed scanner try to match as much as possible in each rule, as |
it's a big win. |
it's a big win. |
.PP |
.PP |
Note that start-conditions names are really integer values and |
Note that start-condition names are really integer values and |
can be stored as such. Thus, the above could be extended in the |
can be stored as such. Thus, the above could be extended in the |
following fashion: |
following fashion: |
.nf |
.nf |
|
|
can be used to control whether the current buffer's scanning |
can be used to control whether the current buffer's scanning |
context for the next token match is done as though at the |
context for the next token match is done as though at the |
beginning of a line. A non-zero macro argument makes rules anchored with |
beginning of a line. A non-zero macro argument makes rules anchored with |
'^' active, while a zero argument makes '^' rules inactive. |
\'^' active, while a zero argument makes '^' rules inactive. |
.PP |
.PP |
The macro |
The macro |
.B YY_AT_BOL() |
.B YY_AT_BOL() |
|
|
switch statement and separated using |
switch statement and separated using |
.B YY_BREAK, |
.B YY_BREAK, |
which may be redefined. By default, it is simply a "break", to separate |
which may be redefined. By default, it is simply a "break", to separate |
each rule's action from the following rule's. |
each rule's action from the following rules. |
Redefining |
Redefining |
.B YY_BREAK |
.B YY_BREAK |
allows, for example, C++ users to |
allows, for example, C++ users to |
|
|
scanner tables should be generated - |
scanner tables should be generated - |
.I flex |
.I flex |
should not compress the |
should not compress the |
tables by taking advantages of similar transition functions for |
tables by taking advantage of similar transition functions for |
different states. |
different states. |
.IP |
.IP |
.B \-CF |
.B \-CF |
|
|
when it has scanned a token like "auto" and then the next character |
when it has scanned a token like "auto" and then the next character |
is something other than a newline or a letter. Previously it would |
is something other than a newline or a letter. Previously it would |
then just match the "auto" rule and be done, but now it has no "auto" |
then just match the "auto" rule and be done, but now it has no "auto" |
rule, only a "auto\\n" rule. To eliminate the possibility of backing up, |
rule, only an "auto\\n" rule. To eliminate the possibility of backing up, |
we could either duplicate all rules but without final newlines, or, |
we could either duplicate all rules but without final newlines, or, |
since we never expect to encounter such an input and therefore don't |
since we never expect to encounter such an input and therefore don't |
how it's classified, we can introduce one more catch-all rule, this |
how it's classified, we can introduce one more catch-all rule, this |
|
|
first way is to simply compile a scanner generated by |
first way is to simply compile a scanner generated by |
.I flex |
.I flex |
using a C++ compiler instead of a C compiler. You should not encounter |
using a C++ compiler instead of a C compiler. You should not encounter |
any compilations errors (please report any you find to the email address |
any compilation errors (please report any you find to the email address |
given in the Author section below). You can then use C++ code in your |
given in the Author section below). You can then use C++ code in your |
rule actions instead of C code. Note that the default input source for |
rule actions instead of C code. Note that the default input source for |
your scanner remains |
your scanner remains |
|
|
.B yy_delete_buffer(), |
.B yy_delete_buffer(), |
and |
and |
.B yyrestart() |
.B yyrestart() |
(again, the first argument is a |
(again, the first argument is an |
.B istream* |
.B istream* |
object pointer). |
object pointer). |
.PP |
.PP |
|
|
respectively. |
respectively. |
.TP |
.TP |
.B virtual int yylex() |
.B virtual int yylex() |
performs the same role is |
performs the same role as |
.B yylex() |
.B yylex() |
does for ordinary flex scanners: it scans the input stream, consuming |
does for ordinary flex scanners: it scans the input stream, consuming |
tokens, until a rule's action returns a value. If you derive a subclass |
tokens, until a rule's action returns a value. If you derive a subclass |
|
|
failed to notice the fact, meaning that |
failed to notice the fact, meaning that |
.I flex |
.I flex |
scanned the first two sections looking for occurrences of these actions |
scanned the first two sections looking for occurrences of these actions |
and failed to find any, but somehow you snuck some in (via a #include |
and failed to find any, but somehow you snuck some in (via an #include |
file, for example). Use |
file, for example). Use |
.B %option reject |
.B %option reject |
or |
or |