[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CSV Parser - Empty values
From: |
Ahsan A. |
Subject: |
CSV Parser - Empty values |
Date: |
Tue, 18 Feb 2003 23:48:30 -0800 (PST) |
Hi,
I'm new to flex & Bison, and I'm trying to write a csv
parser. My question is regarding the lexical scanner:
In a .csv file, if there is line:
one,two,,,three,four,"data,with comma"
I wish to return an EMPTYDATA_TOK if an empty value is
encountered (2 commas without any data in between)
the patterns are:
, {return DELIMETER_TOK;}
\" {return STRDELIMETER_TOK;}
\n {return NEWLINE_TOK;}
[a-zA-Z0-9]* {return DATATOK;}
What I wish to do is return an EMPTYTOK, when an empty
value (between two commas ) is matched.
Since there is no way to match a null value in regex,
is there any other way I could do this ? I tried
declaring two variables int del_start, del_end, and
checking for an empty value in between 2 commas, and
returning an EMPTYTOK, but in that case I need TWO
return statements in one action... which is not
possible...
The bison grammar is fairly simple...
Or would you recommend I write a scanner of my own for
this ? The object of writing this parser is to flex my
knowledge of GNU flex. :)
Regards,
Ahsan
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
- CSV Parser - Empty values,
Ahsan A. <=