In this example, we will develop a simple parser for Comma Separated Value (CSV) files. The rules we will follow are as follows:
- Each record will occupy one line, and newline indicates a new record
- Fields in the record are separated by commas, unless they are within a quoted string
- Strings can be quoted using single (') or double quotes ("), in which case they can contain commas as part of the string
- Quotes immediately repeated ('' or "") is a literal, and a part of the string rather than a delimiter of a string
- If a string is quoted, then spaces outside of the string are ignored
This is a very basic implementation, and omits the usual requirement that quoted strings can contain newlines.
In this example, much ...