Parsing CSV files with Lisp.
Posted: 2011/02/14 Filed under: Lisp, Parsing, Programming | Tags: Lisp, Parsing, Technology 4 Comments »In a previous blog post I talked about the parsing method I use here. It’s a hand made state machine, which (if you do it right) can be remarkably short. This parser parses CSV files. I haven’t widely tested it, but it should be compatible with excel & gmail exported csv files. CSV isn’t standard but generally:
- Use Commas as the deliminator.
- Any field that has a comma or a newline is treated as complex.
- Complex values are wrapped in quotes.
- Quotes in complex values are represented as double quotes.
This parser shoud support any line ending (cr+lf, lf or cr) and handles regular and complex values. I’ve heard of CSV files using C style escapes (like \n) but I’ve never seen one, and this this parser doesn’t support that.
Programming Language Syntax
Posted: 2010/07/15 Filed under: Forth, Lisp, Parsing, Programming, Python | Tags: Compiler, Forth, Lisp, Parsing, Python Leave a comment »In last weeks article I used Python; I didn’t like the experience. I don’t like its syntax which is just like C, C++, Basic, Java, C#, Fortran, &c. These languages maintain an invented separation between statements and expressions. Read the rest of this entry »
Flexible Parsing without Regexps
Posted: 2010/07/07 Filed under: FormLis, Forth, Parsing, Python | Tags: FormLis, Parsing, Python 2 Comments »I had trouble writing a wiki parser for FormLis because it had to feel natural. Some wiki’s require N spaces before the bullet asterisks, or exactly 4 spaces for an indented line. FormLis doesn’t care. The parser I’ve written has no lexer and no regexps. Read the rest of this entry »