[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
successive QUOTEDs
From: |
Shimura Dai |
Subject: |
successive QUOTEDs |
Date: |
Fri, 07 Nov 2003 18:54:51 +0900 |
User-agent: |
Mozilla/4.75 compatible - Mozilla/5.0 |
Hi.
I was trying to extract successive QUOTEDs with flex.
It should take 2 or more QUOTED(i.e. "something")s for one token.
e.g.
"abc" "def" => "\"abc\" \"def\""
Now I don't think I should use flex for this purpose.
I think I should connect them by bison or something in stead.
I'm just very curious.
================================================================================
I wrote a program below, but it doesn't work correctly.
Can anybody correct the program?
$ cat foo.l
%{
%}
text (\\\")|([^\"])
quoted \"{text}*\"
%%
{quoted}+ {printf("quoted:%s\n", yytext);}
. {printf("char:%c\n", *yytext);}
$
wrong example:
$ flex foo.l ; gcc lex.yy.c -lfl ; ./a.out < test1
quoted:"\"","
char:b
char:a
char:r
char:"
correct example:
$ flex foo.l ; gcc lex.yy.c -lfl ; ./a.out < test2
quoted:"\"a"
char:,
quoted:"bar"
$
the input files are....
$ cat test1
"\"","bar"
$ cat test2
"\"a","bar"
$
I'm using flex 2.5.4 .
$ flex -V
flex version 2.5.4
$
--
I don't know the key to success, but the key to failure is to try to please
everyone.
address@hidden
- successive QUOTEDs,
Shimura Dai <=