ocean
Languages and libraries
c compiler
SHOW HN2021
159points
42comments
#303of 2,533 in 2021
Top 12%of 2021 by points
How HN took it
CuriousMostly questions and neutral comments
2 positive, 10 neutral or asking, 0 mixed, 2 critical, out of 14 comments about the project. Thread score +0.03.
Idea: 0 for, 1 againstExecution: 0 for, 1 against
The thread, comment by comment
Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.
positive neutral or mixed critical about another commenter or something else the maker
What HN said
What people liked
Good learning project and great way to learn compilers
From 2 comments
Just a few small suggestions: 1. Some code seems to be duplicated (although with slightly different formatting) across multiple files, like dd/dw/db in elf.c and x86.c for…
thamer on HNGreat job! Writing a compiler from scratch is a massively valuable learning experience. I wrote one in BASIC for the 6502, that became self-hosting on April 24th, 1982. I'm going…
justinlloyd on HN
Objections
Not really a C compiler yet; the function syntax deviates from C
From 1 comment
> Programming language that compiles into a x86 ELF executable. > a compiler somewhat resembling C > Add new or borrow from other language(s) features ontop of C, deviate away…
MisterTea on HN
Requests
Use C-style string handling alternatives such as length-carrying strings
From 1 comment
If you are exploring alternatives to the stdlib, you might commit yourself to no zero terminated strings and see where it takes you. A fundamental data type with a pointer, a…
jeffrallen on HN
Questions
What resources were used to learn compiler construction
From 1 comment
Any specific resources you've used that you could recommend in line with compiler construction?
kinga254 on HN
Alternatives named
Flex and Bison / yacc
From 2 comments
This is just an anecdote, but I had to write a SQL DDL and DML parser during my last semester. I wrote the DDL parser by hand, and it wasn't as bad as I expected, but it was time…
jjice on HNYou could use https://en.wikipedia.org/wiki/Yacc I decided to write my own lexer/parser/compiler it's pretty straightforward. Sources I use(d) to program this, e.g look at…
r1chardnl on HN
ANTLR
From 2 comments
I wrote a C compiler* using flex [1] and bison [2] that generated MIPS code. The biggest downside was the rather complex glue code. At some point ANTLR [3] looked promising, but…
optymizer on HNI've had good luck with ANTLR4 and ObjWeb ASM for my JVM language Imp https://github.com/mh15/imp
MH15 on HN
Crafting Interpreters
From 1 comment
This is specific to interpreters but the beginning part related to parsing and AST is common: http://craftinginterpreters.com/contents.html
blcArmadillo on HN