#csv #parser #show #pest-parser #built #grammar #basic

bin+lib csv_parser_moshkovskyi

CSV parser built with Pest parser for Rust

1 unstable release

0.1.0 Nov 14, 2024

#2487 in Parser implementations

MIT license

9KB
97 lines

CSV_PARSER_MOSHKOVSKYI

Realisation of basic csv parser

Technical description

This parser is parsing a csv file. He will parse file, show it in structured way and check file on correctnes.

Usage

The result can be used for basic data analytics

Grammar

WHITESPACE = _{ " " | "\t" | "\n" | "\r" } NEWLINE = _{ "\n" | "\r\n" } csv = { (WHITESPACE | NEWLINE)* ~ record ~ (NEWLINE ~ record)* ~ (WHITESPACE | NEWLINE)* } record = { field ~ ("," ~ field)* } field = { empty_field | quoted_field | unquoted_field } empty_field = _{ "," } quoted_field = _{ """ ~ (!""" ~ ANY | """ ~ """)* ~ """ } unquoted_field = _{ (!("," | NEWLINE | " ") ~ ANY)+ }

Dependencies

~5MB
~85K SLoC