Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

	    ==============================================
			  Simply Parse in C
	    A Working INI File Parser in ~150 Lines of C99
		 from the paper by Chloe Kudryavtsev
	    ==============================================



Introduction and Overview
-------------------------

Chloe Kudryavtsev (CK) wrote a paper in July of 2023 to demonstrate
that parsers aren't really all that complex. The original is at
https://pencil.toast.cafe/bunker-labs/simply-parse-in-c (as of October
2024).

This repository is my read- and work-through of the paper. I don't
expect to do anything meaningfully original here, but my stuff is
always public domain (see License below). CK placed no license or
copyright notice on the paper, nor did I find one elsewhere on her
site.

Troy Brumley, [email protected], October 2024.

So let it be written,
So let it be done.



License
-------

Either public domain under the UNLICENSE, or MIT as you like.



Dependencies and Tooling
------------------------

This is all built on a MacBook M2 using Apple's current standard
Clang. I'm transitioning from GNU Make to CMake and Ninja. Formatting
is done every time a file is saved using Artistic Style. I edit with
Emacs using Eglot, Treesitter, and Clangd. I compile with "-Wall
--pedantic-errors -Werror -std=c18" for all builds. Debug builds add
"-g3 -fsanitize=address".



Code Notes
----------

The original code as pulled from the paper is in a separate directory
from my experiments with it. My editor formatters will change tabbing
and might move some braces around, but the code is meant to be
identical to the original. Some minor bugs were found and fixed, these
are noted by comments flagged 'txb'.

I'll did my work through in another directory and then redid most of
the code to make something suitable for inclusion in my libraries. in
so doing I tightened up some behavior (missing keys or values were
ignored in the original). 

The original was advertised as taking about 150 lines. 'cloc' reports
157 lines so mission accomplished.

The workthru/rewrite is reported as having 206 lines of code. Not 
bad at all.

Additions
---------

1. I threw together a quick Object Pascal version just to play with
   callbacks and streams. The parse is the same, but I didn't bother
   to package it s a unit. `sloccount` reports 180 lines of code.  

2. The original article domain's certificate is outdated and I could
   not reference it (October 2025). I downloaded a snapshot from the
   wayback machine using the single file browser plugin to preserve
   a copy for quick reference.

About

an ini file parser based on the article "Simply Parse in C"

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages