Browsable Comma-Separated Values (CSV) Grammar

CC-BY

Grammar connected by Vadim Zaytsev, see the Grammar Zoo entry for details: markup/textual/csv/bucknall/connected
Source used for this grammar: Julian M. Bucknall, Writing a Parser for CSV Data, 11-jul-2005; 27-oct-2005 [Online]

Summary

Syntax

csvFile ::=
	csvRecord* EOF
csvRecord ::=
	csvStringList ("\n" | EOF)
csvStringList ::=
	rawString ("," csvStringList)?
rawString ::=
	optionalSpaces (rawField optionalSpaces)?
optionalSpaces ::=
	whitespace*
whitespace ::=
	" "
	"\t"
rawField ::=
	simpleField
	quotedField
simpleField ::=
	¬("\n" | EOF | "\t" | " " | "," | """)+
quotedField ::=
	""" escapedField """
escapedField ::=
	subField (""" """ escapedField)?
subField ::=
	¬(""" | EOF)+

GrammarLabMaintained by Dr. Vadim Zaytsev a.k.a. @grammarware. Last updated in September 2015. []