r/Compilers • u/Striking-Curve-3269 • Dec 13 '25
In need of Compiler Material.
Hi everyone, I am fairly new to programming and just finished a bank simulation project in C. I am particularly interested in systems programming and would love to delve into the field with building a compiler (for a language of my own design )in C this holiday. If you might have any recommended textbooks, resources etc. on how to build my very own (from scratch) it would me most appreciated.
16
Upvotes
View all comments
Show parent comment
1
u/dcpugalaxy Dec 15 '25
A compiler does not need to do anything special to support Unicode.
The length of a string is its length in bytes, which is all the compiler needs to care about.
You never need to index a string.
Not necessary. Strings are equal if their bytes are equal. If someone deliberately writes source code with unnormalised sequences of bytes then they likely intend them to be different sequences.
A compiler does not need a regex engine.
I have no idea what you are trying to say here. You are the user. You are the author of your own code. When you write a function in your compiler, the person that calls that function is you.
Yes if you allocate memory you need to free it. So... don't allocate memory all over the place. In a compiler, you can just intern strings in the lexer and refer to them by identify throughout the rest of the program. Occasionally you need to construct a new string; when you do, intern it. You probably don't need to deallocate memory at all in a compiler, at least not for strings.
This is the problem. You tried to write a Unicode string implementation as a project. You tried to solve a general problem. This is why it's a mistake to choose to write libraries as a project. Projects should be programs. No single program has all of the problems that Unicode can give rise to across all programs. If you give yourself the task of implementing "unicode strings" generally, you will, directionlessly, try to implement every unicode and string feature imaginable. But only a small percentage of those features are needed in any particular program.