c_compiler playground

1 view
Skip to first unread message

Mark Wutka

unread,
Jan 28, 2026, 8:43:59 AMJan 28
to nashfp
Hi everyone!  I created the c_compiler playground on Github:

While I do have implementations of chapter 1 in Ada and Rust, I didn't include them, just
the Ocaml version. If anyone wants those, I can add them. One thing I am doing that
the book doesn't mention is that I am tracking the filename, line number, and column
for each token (this actually precluded me using nom in Rust). It's a pain, but I like being
able to point to a particular filename, line and column when reporting an error. If you
choose to do that, remote -P from the "gcc -P -E ..." line in driver.sh so it will emit lines
starting with # like this:
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "tabs.c"
int main ( void) { return 99 ; }

The first number is the line number, and then the filename. I ignore the rest.
  Mark

Reply all
Reply to author
Forward
0 new messages