mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-11-13 22:55:29 +00:00
19 lines
512 B
Plaintext
19 lines
512 B
Plaintext
#
|
|
# 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
|
|
escaped <- DQUOTE (TEXTDATA / COMMA / CR / LF / D_DQUOTE)* DQUOTE
|
|
non_escaped <- TEXTDATA*
|
|
COMMA <- ','
|
|
CR <- '\r'
|
|
DQUOTE <- '"'
|
|
LF <- '\n'
|
|
NL <- CR LF / CR / LF
|
|
TEXTDATA <- !([",] / NL) .
|
|
D_DQUOTE <- '"' '"'
|