Skip to content
melt-srcPublic

About

A simple parsing library in C. Currently features CSV format and string parsing.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

Repository files navigation

ChopDat! A simple parsing library

ChopDat is a work in progress parsing library. It currently supports only CSV (Comma Separated Values) parsing, but is soon going to support many other file formats.

Parsing CSV files

The library provides CSV parsing features through a recursive descent approach. The supported context-free grammar is a simplified version of the official CSV grammar from RFC 4180, written in BNF (Backus-Naur Form); in classic matemathical language:

records = enclosed_token COMMA records / enclosed_token CRLF / e

enclosed_token = DQUOTE token DQUOTE

token = TEXTDATA token / TEXTDATA

CRLF = %x0D%x0A
COMMA = %x2C
DQUOTE = %x22
TEXTDATA = %x00-09 / %x0B-0C / %x0E-21 / %x23-10FFFF

This simplified grammar assumes that:

  • a CSV file is a sequence of records (including the empty sequence),
  • a record is structured into enclosed_token (s) separated by COMMA (s) and ending in a CRLF (i.e. Carriage Return, Line Feed),
  • an enclosed_token is structured as a token enclosed in DQUOTE (s) (double quotes),
  • a token is a sequence of at least one unicode character, except from double quotes, carriage returns and new lines.

Imposing such limitations to the original grammar, thus to the language it generates, largely eases the complexity of our parser. Nonetheless, being this CSV “dialect” quite common, this parser allows real world usage.

About

A simple parsing library in C. Currently features CSV format and string parsing.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages