mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Added csv.peg.
This commit is contained in:
parent
64e7274b1d
commit
7a81ced514
18
grammar/csv.peg
Normal file
18
grammar/csv.peg
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# 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 / TWO_DQUOTE)* DQUOTE
|
||||||
|
non_escaped <- TEXTDATA*
|
||||||
|
COMMA <- ','
|
||||||
|
CR <- '\r'
|
||||||
|
DQUOTE <- '"'
|
||||||
|
LF <- '\n'
|
||||||
|
NL <- CR LF / CR / LF
|
||||||
|
TEXTDATA <- [\x20-\x21] / [\x23-\x2B] / [\x2D-\x7E]
|
||||||
|
TWO_DQUOTE <- '"' '"'
|
Loading…
Reference in New Issue
Block a user