cpp-peglib/grammar/csv.peg

19 lines
512 B
Plaintext
Raw Normal View History

2015-02-23 03:48:41 +00:00
#
# CSV grammar based on RFC 4180 (http://www.ietf.org/rfc/rfc4180.txt)
#
file <- (header NL)? record (NL record)* NL?
header <- name (COMMA name)*
record <- field (COMMA field)*
name <- field
field <- escaped / non_escaped
2015-02-27 03:06:54 +00:00
escaped <- DQUOTE (TEXTDATA / COMMA / CR / LF / D_DQUOTE)* DQUOTE
2015-02-23 03:48:41 +00:00
non_escaped <- TEXTDATA*
COMMA <- ','
CR <- '\r'
DQUOTE <- '"'
LF <- '\n'
NL <- CR LF / CR / LF
TEXTDATA <- !([",] / NL) .
2015-02-27 03:06:54 +00:00
D_DQUOTE <- '"' '"'