On Wed, Dec 19, 2007 at 02:50:55PM +1100, Ian Wienand wrote:
> [ C version ]

Here's one in lex; ripped off from the flex info page.
I'd be interested in its performance compared to straight C.
No doubt worse, just curious how much worse.


$ cat count.l

cat count.l
    int num_commas = 0;

%%
,     ++num_commas;
.|\n       {}

%%
main()
{
    yylex();
    printf( "# of commas = %d\n",
        num_commas );
    return 0;
}

$ lex -t count.l > count.c
$ cc count.c -lfl -o count
$ echo dsfsdf,,,, | ./count
# of commas = 4





-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to