Commit a6a49ce9dd785728d7b7b0b08af3477ab90b3599
1 parent
2028e811
fixed a regular expression
Showing
1 changed file
with
10 additions
and
10 deletions
Show diff stats
anubis_dev/library/data_base/read_csv.anubis
| ... | ... | @@ -43,21 +43,21 @@ define List(LexerItem(CellPrefixToken,One)) |
| 43 | 43 | String sep |
| 44 | 44 | ) = |
| 45 | 45 | [ |
| 46 | - lexer_item("[^#"+sep+"\"#r#n]*\"", | |
| 46 | + lexer_item("[# #t]*\"", | |
| 47 | 47 | return(((Int,Int) -> ByteArray extract, Int l, LexingTools t, One u) |-> |
| 48 | 48 | token(double_quote))), |
| 49 | 49 | |
| 50 | 50 | lexer_item("[^#"+sep+"\"#r#n]*#"+sep, |
| 51 | 51 | return(((Int,Int) -> ByteArray extract, Int l, LexingTools t, One u) |-> |
| 52 | - t.back(1); token(separator(extract(0,l-1))))), | |
| 52 | + token(separator(extract(0,l-1))))), | |
| 53 | 53 | |
| 54 | 54 | lexer_item("[^#"+sep+"\"#r#n]*#n" , |
| 55 | 55 | return(((Int,Int) -> ByteArray extract, Int l, LexingTools t, One u) |-> |
| 56 | - t.back(1); token(separator(extract(0,l-1))))), | |
| 56 | + token(separator(extract(0,l-1))))), | |
| 57 | 57 | |
| 58 | 58 | lexer_item("[^#"+sep+"\"#r#n]*(#r#n)" , |
| 59 | 59 | return(((Int,Int) -> ByteArray extract, Int l, LexingTools t, One u) |-> |
| 60 | - t.back(2); token(separator(extract(0,l-2))))) | |
| 60 | + token(separator(extract(0,l-2))))) | |
| 61 | 61 | ]. |
| 62 | 62 | |
| 63 | 63 | |
| ... | ... | @@ -82,7 +82,7 @@ define List(LexerItem(InToken,One)) |
| 82 | 82 | lexer_item("\"\"" , |
| 83 | 83 | return((ByteArray b, LexingTools t, One u) |-> token(two_double_quotes))), |
| 84 | 84 | |
| 85 | - lexer_item("\"" , | |
| 85 | + lexer_item("\"[# #t]*(("+sep+")|(#n)|(#r#n))" , | |
| 86 | 86 | return((ByteArray b, LexingTools t, One u) |-> token(double_quote))) |
| 87 | 87 | ]. |
| 88 | 88 | |
| ... | ... | @@ -95,7 +95,7 @@ define List(LexerItem(One,One)) |
| 95 | 95 | String sep |
| 96 | 96 | ) = |
| 97 | 97 | [ |
| 98 | - lexer_item("(([^\"#n#r#"+sep+"]*)|(\"([^\"]|(\"\"))*\"))#"+sep, | |
| 98 | + lexer_item("(([^\"#n#r#"+sep+"]*)|([# #t]*\"([^\"]|(\"\"))*\"[# #t]*))#"+sep, | |
| 99 | 99 | return(((Int,Int) -> ByteArray b, Int l, LexingTools t, One u) |-> token(unique))) |
| 100 | 100 | ]. |
| 101 | 101 | |
| ... | ... | @@ -209,7 +209,7 @@ define List(One -> CB_Result) |
| 209 | 209 | { |
| 210 | 210 | [ ] then [to_eol], |
| 211 | 211 | [n . l] then |
| 212 | - with rest = make_cbs(skip_cell,read_cell,to_eol, map((Int x) |-> x - n,l)), | |
| 212 | + with rest = make_cbs(skip_cell,read_cell,to_eol, map((Int x) |-> x - n -1,l)), | |
| 213 | 213 | constant_list(skip_cell,n) + [read_cell . rest] |
| 214 | 214 | }. |
| 215 | 215 | |
| ... | ... | @@ -249,7 +249,7 @@ public define One -> ReadCsvResult |
| 249 | 249 | skip_cell = (One u) |-> (CB_Result)if lex_skip(u) is |
| 250 | 250 | { |
| 251 | 251 | end_of_input then eof, |
| 252 | - error(b,line,col) then error("skip "+to_string(b)), | |
| 252 | + error(b,line,col) then error("skip "+line+":"+col+" :"+to_string(b)), | |
| 253 | 253 | token(t) then skip |
| 254 | 254 | }, |
| 255 | 255 | begin_cell = (One u) |-> (Result(String,CellPrefixToken))if lex_begin(u) is |
| ... | ... | @@ -398,7 +398,7 @@ global define One |
| 398 | 398 | { |
| 399 | 399 | failure then print("File '"+path+"' not found.\n"), |
| 400 | 400 | success(f) then |
| 401 | - if make_lexing_stream("",f,1000,10) is | |
| 401 | + if make_lexing_stream("",f,10,10) is | |
| 402 | 402 | { |
| 403 | 403 | failure then print("Error while reading file '"+path+"'.\n"), |
| 404 | 404 | success(ls) then |
| ... | ... | @@ -406,7 +406,7 @@ global define One |
| 406 | 406 | read_line = make_read_csv_line(ls,sep,cs), |
| 407 | 407 | // show_perf(read_line, 10000) |
| 408 | 408 | print_to_error(read_line) |
| 409 | - } | |
| 409 | + } | |
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | else syntax | ... | ... |