Related articles |
---|
flex default rule dmaziuk@bmrb.wisc.edu (Dimitri Maziuk) (2006-04-01) |
Re: flex default rule johnmillaway@yahoo.com (John Millaway) (2006-04-03) |
Re: flex default rule dmaziuk@bmrb.wisc.edu (Dimitri Maziuk) (2006-04-03) |
Re: flex default rule cdodd@acm.org (Chris Dodd) (2006-04-03) |
Re: flex default rule dmaziuk@bmrb.wisc.edu (Dimitri Maziuk) (2006-04-08) |
From: | Dimitri Maziuk <dmaziuk@bmrb.wisc.edu> |
Newsgroups: | comp.compilers |
Date: | 1 Apr 2006 20:49:58 -0500 |
Organization: | only myself |
Keywords: | lex, question |
Posted-Date: | 01 Apr 2006 20:49:58 EST |
Hi all,
here's what I can't quite figure out:
Rule: multi-line text values are enclosed in "\n;"
Relevant flex specs:
NL (\r|\n|\r\n)
WS [ \t\r\n\b\012]
SEMI ^;
%x YYSEMI
%option c++
%debug
%%
<INITIAL>{SEMI} {
cerr "Entering YYSEMI" << endl;
BEGIN YYSEMI;
}
<YYSEMI>{SEMI} {
cout << buf.c_str() << endl; // buf is an std::string
BEGIN INITIAL;
}
<INITIAL>[^{SEMI}] {
cerr << "in YYSEMI, token" << yytext << endl;
buf.append( yytext );
}
Input:
;
Solution Structure and Backbone Dynamics of Component IV
Glycera dibranchiata Monomeric Hemoglobin-CO
;
Final output (from second rule):
olution tructure and Backbone Dynamics of Component V
Glycera dibranchiata onomeric Hemoglobin-CO
Trace output:
--accepting rule at line 114(";")
Entering YYSEMI
--accepting rule at line 189("
")
in YYSEMI, token:
--(end of buffer or a NUL)
--accepting default rule ("S")
--(end of buffer or a NUL)
S--accepting rule at line 189("o")
in YYSEMI, token: o
...
--accepting rule at line 189("n")
in YYSEMI, token: n
--(end of buffer or a NUL)
--accepting rule at line 189(" ")
in YYSEMI, token:
--(end of buffer or a NUL)
--accepting default rule ("S")
--(end of buffer or a NUL)
S--accepting rule at line 189("t")
in YYSEMI, token: t
--(end of buffer or a NUL)
...
--accepting rule at line 189("t")
in YYSEMI, token: t
--(end of buffer or a NUL)
--accepting rule at line 189(" ")
in YYSEMI, token:
--(end of buffer or a NUL)
--accepting default rule ("I")
--(end of buffer or a NUL)
I--accepting rule at line 189("V")
in YYSEMI, token: V
...
and so on.
Why the hell does it trigger the default rule at 'S', 'S', 'I', and 'M'?
Any takers?
TIA
Dima
Return to the
comp.compilers page.
Search the
comp.compilers archives again.