Debian Codegraph @

inttest/neotoma1/src/csv.peg

raw
1 rows <- head:row tail:(crlf row)* / ''
2 `
3 case Node of
4 [] -> [];
5 [""] -> [];
6 _ ->
7 Head = proplists:get_value(head, Node),
8 Tail = [R || [_,R] <- proplists:get_value(tail, Node)],
9 [Head|Tail]
10 end
11 `;
12
13 row <- head:field tail:(field_sep field)* / ''
14 `
15 case Node of
16 [] -> [];
17 [""] -> [];
18 _ ->
19 Head = proplists:get_value(head, Node),
20 Tail = [F || [_,F] <- proplists:get_value(tail, Node)],
21 [Head|Tail]
22 end
23 `;
24 field <- quoted_field / (!field_sep !crlf .)* `iolist_to_binary(Node)`;
25 quoted_field <- '"' string:('""' / (!'"' .))* '"'
26 `
27 String = proplists:get_value(string, Node),
28 re:replace(String, "[\"]{2}", "\"",[global, {return, binary}])
29 `;
30 field_sep <- ',' ~;
31 crlf <- [\r]? [\n] ~;