LCC elegantly simplifies the daunting architecture of compiler frontends into a modular, accessible framework for developers. It successfully bridges the gap between complex language theory and practical, hands-on implementation.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
MAKE YOUR PROGRAMMING LANGUAGE TODAY | Overview of The Creation of An LCC FrontendAdded:
Today, we're going to go through the basics of writing a very simple toy language that you'll probably find looks very familiar.
There's this document. There's a link in the description if you'd like to look at it.
It's available in the Lenser compiler collection repository on Codeberg, sadly still on GitHub as well.
Under documentation/lcc/implementingmyownlanguage.org.
And of course, because it's Emacs and org-mode, you could export it to any format that you'd like to read it in.
So, you want to write a programming language? Even if you don't, if you just want to see how LCC makes it easier to write a programming language, stick around.
You've come to the right place. This file is meant as a very basic overview or rundown of the steps you would take to introduce any new language to the LCC code base. And it is non-exhaustive.
There is more to do.
First things first, the driver, I kind of go for a top-down approach, right?
So, if we just give a little uh we've got like GCC and clang and LCC, right? These are not actually compilers, they're compiler drivers. If you'll notice, when you run GCC, here, let's jump over to a terminal here.
See if I can make this bigger.
Not too big.
So, you'll notice, like if you Here.
Got a little test program here.
If you're to compile test.c, right? And let's just say you go -o test, right?
That way you can do ooh, dot slash test.
Is 50 what?
Hold on.
Just got to uh verify something here.
Okay. Yeah, that's the right answer.
Got a little scared there.
Anyway, when you do this, you'll notice if you run -v, all right, that seems to have worked.
Here is our our final compile Well, this is a link, so you see the collect two is our linker.
And then if we uh if we move on up here, look for these little indents where a command is run, you can see we ran as on something a.o file, which was generated as is the GNU assembler, which was generated by cc1, right here.
As you can see, GCC is running the compiler, cc1, to generate an object file, which it then assembles to generate an assembly file, which it then assembles into an object file, which it then links with all the uh system linking goodness, right? If you uh you didn't know.
Look at that.
Look at that.
All that to say, GCC, Clang, and LCC are compiler drivers.
So, if you're going to be writing a compiler for your language, what that really means is you're writing one of these programs or part of one of these programs.
So, we've got the cc1.
That's the compiler, the C compiler.
So, effectively, if you were going to implement the C language, you would try to implement this, and then LCC would just have to know about it and call it.
So, LCC isn't quite as um portable as GCC, we'll say.
So, it doesn't actually call shell commands of environment variables to drive compilation.
It just has a fixed set of steps that it applies, and languages can write a little implementation to do that. Called the driver library. And actually, there's only one thing it needs to implement. So, you just need to make a little C++ header, and you just need to implement produce module in a namespace of your choice.
Ideally, this is in the style This is how the languages are formatted. For example, you can run on over here to driver.hh.
So, this is a real driver in the LCC code base.
And this is the header. You'll notice it's identical.
It's not magic. This is actually all that is needed to implement your language.
What you then do, ignoring ignoring implementing that.
What you then do, hop on over to if you can see at the bottom here, source/ lcc.cc.
There's a function called generate output file, which takes an input file path, and generates an output file path based on the input file if it's or uh context like compiler options. So, all we got to do is scroll down here.
Oh, hey. Hey, that looks familiar. If options language equals IR.
Okay, what if it wasn't IR? Is there an else if? Oh, hey look, they return. So, you don't need an else if. You can just have another if. If options language equals glint. Ah.
And what is what are these doing? Oh, they're calling produce module parse, which produces a module within a mit a module.
And that's it. That's all you need to implement your language. So, add a little if here for your language. For example, for the one we were just looking at, here it is.
And make sure you change the the actual settings here.
So, if if the user selects a language specifically, use that.
Otherwise, base it on what the path ends with. For example, if it ends in dot c, it's probably the c language.
So, that's it. Produce module implemented here.
Now, we can jump over to the implementation in lib.
And you can see it's actually not that much harder to read. It's very simple.
You parse the file.
If the context has an error, you return null putter.
If we were requested to stop at parsing, we return null putter.
We then perform semantic analysis. We generate using IR generation from our little translation unit that we've parsed.
Make some IR and then we return that IR.
That is it.
If your language was brainfuck, I think you could imagine how to implement a parser.
S- sema, for brainfuck, I'm not sure there really is any. You could make sure the pointer doesn't do funky stuff, wrap around, but I think that's a that's a feature, not a bug. So, brainfuck, probably no sema. For C, you can type check and make sure things are not fucky-wucky in your translation unit. So, that's good. You should probably do that.
And then you can generate your IR from what is effectively your AST.
This this is code generation right here.
And this generates LCCIR.
Or Oh, yeah, you probably also want to add in source {slash} source {slash} cli.cc.
You probably want to scroll down here and look for uh language {dash}x, right?
And make sure your list your language is added to this list. Otherwise, if a user tries to specify your language on the command line, the driver won't recognize it. It'll say, "Hey, that's invalid. We don't know what the hell that is." So, yeah, source {slash} lcc.cc, which contains main and stuff like that.
Add your language. Source {slash} cli.cc.
Add your language name, and then everyone should be able to use your language. Of course, when you add when you go to call your produce module, you're going to have to add your include. So, I just go find the the language includes and add add it there.
Right? Make sure you include your header.
You'll probably also need to build your your language.
LCC already supports like separating your language into a library. It does use C make, so it can be a little complicated. Don't worry. Just scroll past anything and look for language, once again.
Hey, look. Find a language library that looks nice to you that isn't too intimidating.
And just it's not going to be the end of the world. Copy and paste.
Rename it to a unique target name.
Usually language and then the name of your language.
Not complicated.
Make sure you link with options such that you inherit all of the build options that have been configured and you want to include include so that your header can actually be found. You know, that'd be nice. And then just list all your files there. No problem.
Once you do that, one line down here.
Link libraries with your language.
Just use that unique identifier that you that you wrote up there.
And that is it.
That will get you a building thing. Of course, you likely don't have anything implemented in your driver.
So, all of these are going to be stubs and you're probably just going to return null pointer at the end.
That's fine.
You'll figure it out.
I promise. You'll figure out how to parse a language.
You know why?
Because LCC makes it easy. That's why.
Look at this. Just look. Just take take a look-see. That's all I'm saying, okay?
So, again, header include LCC syntax lexer include LCC syntax lexer and LCC syntax token.
Here's how you make a lexer.
Yeah, that's it.
That's a UTF-8 ASCII lexer.
That's it. That's your implementation.
Do you like that? I feel like that's easier than maybe some people have shown you in the past how to make a lexer.
And they make it way too complicated.
Just follow this document, make your own language. I want to see your language.
Fork LCC, follow this document, and make a little toy language. Spend a weekend learning something, doing something. I want to see you succeed. I want to see you progress. As always, check out the Discord.
We we do lots of ridiculous talking in the Discord about coding and philosophy and all sorts of things. And if you have questions about LCC, that's a great place to put them.
Other than that, uh hopefully you enjoyed that little rundown of a language front end in LCC and how easy it would be for you to implement your own language using LCC.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 viewsโข2026-05-28
How agent o11y differs from traditional o11y โ Phil Hetzel, Braintrust
aiDotEngineer
450 viewsโข2026-05-28
Re: ๐ฃ๏ธ๐theprophedu๐2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 viewsโข2026-06-04
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation๐ฏโ
LearnwithSahera
1K viewsโข2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 viewsโข2026-05-29
Search Algorithms Explained in 60 Seconds! ๐ค๐จ
samarthtuliofficial
218 viewsโข2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 viewsโข2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 viewsโข2026-05-29











