I haven't done that LISP project, but I recommend Crafting Interpreters.
I know that you say you want to build a compiler. And this tripped me up when I first started. But an interpreter and a compiler are very, very similar--to the point of being nearly identical. You can build a compiler by building an interpreter, then swapping out the immediate-calculation functions for functions that generate machine code (or LLVM IR or whatever). You will often want at least a basic interpreter for your language anyway, if for no other purpose than simplifying expressions.
I also recommend the "Dragon Book", which is pretty much the textbook on compiler design. Reading this book was absolutely eye-opening, because it presents a bunch of very basic and general information that everybody in language design just assumes you know.
I really struggled when I started before I read this book because so much stuff is very much simpler than I imagined. For instance, for my first language project, I got stuck on codegen and never finished. I was stuck on the basic question: okay, but how do I know what order to generate the code in? It seemed like a very hard question, requiring DAGs and dependency analysis and all sorts of shit like that, and I got discouraged and quit. Especially because so many tutorials are like "now that you've parsed your language, interpreting it is easy and left as an exercise for the reader". Guess what? It is easy. It's just a brain-dead post-order traversal. But literally the only place that ever said it that simply and directly was the Dragon Book.
This book was recommended in one of the other discussions. I can vouch for it personally myself.
The linker script in the OP is a useful resource in also just understanding what kind of information you need to track down to build a script from scratch for a new platform:
I've gotten interested in how the linker works so I've been going over this book for a while (https://www.amazon.com/Linkers-Kaufmann-Software-Engineering-Programming/dp/1558604960) and I think it 's an amazing read.
You'd think it'd be out of date but it's very informative since embedded is stuck in the past anyways, and linkers haven't changed too much since then. It even has a section on gnu linker scripts!
> Programming principles and practice
Let me look at the book. C++ books will often have the C++ grammar as an appendix at the end of the book. I suspect this is simply part of the book itself.
EDIT: I looked at the book on Amazon and the grammar appears to be for a simple calculator - and not the C++ grammar. Understanding a grammar will be difficult for you if you have not been formally trained at university in computer science. Explaining grammars is probably too complicated for this sub. I don't know what to really tell you. If you have not studied this in college, then you are probably in a bit over your head.
Most of us who studied CS are familiar with the dragon book. This is kind of the quintessential introduction to compilers and grammars and parsers and tokenizers. You will probably be a bit lost if you have not read this book or something similar.
EDIT2:
Here is a reasonable college level introduction to compilers.
Do you need type inference? If not you can look at the presentation of static typing in this book, which doesn't have any theory:
https://www.amazon.com/Language-Implementation-Patterns-Domain-Specific-Programming/dp/193435645X
I would love to contribute to GCC but I don't have a solid compiler background. Where do you guys suggest I start? Something like this book? Just jumping in and seeing what sticks?
Macroeconomists have the purple book on international macro.
Computer scientists have the purple dragon book on compilers.
They serve roughly the same purpose.
No nessuna risorsa che mi viene in mente al momento.
Ma ci sono due questioni molto interessanti nella costruzione di un compilatore.
Senza usare termini precisi in nessun ambito, l'interpretazione (da codice sorgente ad AST) e la sintesi (da AST a binario).
L'interpretazione è molto più accademica, la sintesi di solito è più pratica.
Per diventare capaci a livello di C secondo me capire bene la sintesi è fondamentale.
Detto questo se trovi qualsiasi cosa che parla di come creare un compilatore, di sicuro spiega i dettagli.
Il libro, che non ho mai letto ma che di fama la fa da padrone, è il libro del drago: https://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811
Il libro del drago, spesso viene contrapposto al SICP, altro libro must che dovrebbe essere letto. E in questo caso per esperienza posso dire che merita una lettura!
https://www.amazon.com/Engineering-Compiler-Second-Keith-Cooper/dp/012088478X
This is the book my compilers course used, it gets into optimization a good bit. You can find pdfs of this online pretty easy.
Get the “dragon book”. There is nothing else like it.
It’s harder than you think. And something viscerally satisfying when you understand how it all works.
https://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811
I think this is one of the best books for stuff like this: Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages (Pragmatic Programmers) https://www.amazon.com/dp/193435645X/ref=cm_sw_r_cp_api_glt_i_4YGH52MGZ6CT4X5M4K7K
Don't worry about the fact that it is about ANTLR3; the theory is adaptable to whatever tech you're using.
If you want a reference book, I think this might be interesting. I did not read it, so I can't vouch for it, but I saw several people recommend it:
https://www.amazon.com/Linkers-Kaufmann-Software-Engineering-Programming/dp/1558604960
As to how you become to understand it, as with anything, just work with them. Change it, see what happens, what is different. Check out the compiler manual, that should outline a lot of the syntax and illuminate the usage. See where the sections come from the code, check the mapfile and see what is actually put in there.
What do you want to do, more exactly? You want to change it in order to... what? What compiler and what target are you using?
What have you tried? How did you fail?
Have you read the VHDL LRM?
Do you know anything about compiler design? The syntax analysis is the same. Have you heard of the dragon book? That's pretty much the definitive book on compiler design.
The book I see recommended most frequently these days is Engineering a Compiler by Cooper and Torczon (Amazon link). But compilers isn't really my specific area so I don't keep up to date with every possible recommendation!
I can't help you with specifics but if you're looking for something in depth, the answers you're looking for may be in here.
আমি তেমন ভালো ভাবে বোঝাতে পারি না। প্রোগ্রামিং ভাষা কিভাবে কাজ করে জানতে চাইলে আমার থেকে ভালো সোর্স হচ্ছে craftinginterpreters.com/ অথবা dragon book।
Consider making informative videos about what you already know but using the correct terminology and jargon if thats what you're talking about. If you make a tutorial, even if you dont publish it to the public, you spend a lot of time using the correct terms in the correct place. This is what university was handy for, it cost me a ton to learn what all the jargon and terms are, you can do it for free but at university they ram it into your skull. But the ramming is done via homework and lecture and whatnot, so if you do your projects out loud explaining things as you go, and get good at explaining with the correct terms you should be good. As far as books, i liked the cheap version of the pragmatic programmer... aka. Programming Language Pragmatics by Michael L. Scott amazon
I'd recommend Programming Language Explorations:
Or Programming Language Pragmatics:
https://www.amazon.com/Programming-Language-Pragmatics-Michael-Scott/dp/0124104096/ref=sr_1_1
I'd say the former is more fun to read, while still providing a lot of insight, and the latter is more comprehensive.
Why not SML or ml or another language more is less designed for this task. I can recommend this book! It took my understanding of compilation to a whole new level. https://www.amazon.com/Modern-Compiler-Implement-Andrew-Appel/dp/0521607647
Due to the nature of the problem at the time though. Eh, I find Engineering a Compiler to be significantly expressive and concise, which is a complete pile of unfinished shite).
Then I don't get what are the columns then (hence my running total aside the input column).
This is the book you're referring to ? https://www.amazon.fr/Engineering-Compiler-Keith-Cooper/dp/012088478X
I for one advocate the approach of learning bits of assembly first and then jumping to C. I taught my students like this for the last 6 years and it worked wonders. Try this book to see how:
https://www.amazon.com/Low-Level-Programming-Assembly-Execution-Architecture/dp/1484224027
A quick googling showed that it's easy to find a PDF online ;)
> What book to read to understand how to develop a general compiler?
A lot of people recommend Compilers: Principles, Techniques, and Tools (AKA the Dragon Book), but a Redditor recommended Engineering a Compiler, and I think it's the better book.
There are two aspects of compiling and linking: a pragmatic application of tools to get the job done and the actual mechanisms these tools use to put the bits and bytes together. On the pragmatic side, you have build systems like autoconf, CMake, ninja, and others (though the first two are the most prevalent). There are a multitude of books and online resources for learning how to use these tools. I don't use CMake, myself, but I can recommend some books on autoconf, if you are interested.
For the more technical details of how compilers and linkers work together to make an executable, there is a real dearth of information on the internet about this and even fewer books that cover it with any regard. In fact, I have only found two books that cover the material with any real depth: John Levine's <em>Linkers and Loaders</em> and Milan Stevanovic's <em>Advanced C and C++ Compiling</em>.
it sort of depends on what you are trying to do.
I can't really tell from the name what that book is going to cover, but I expect that most books on programming language theory are going to start with things like lambda calculus, and go into type theory, etc, etc. If you are trying to learn the theoretical underpinnings of programming languages then this is great!
However, in my opinion a more practical place to start is with learning how to implement a programming language. That is, how to write a compiler. For that there is a whole separate set of theory (regular expressions, grammars, automata, etc) that you need to learn. The standard text for this is "the dragon book".
Writing a lambda in, eg, Lisp is indeed a few lines of code, but the same process of translation down to binary will still happen, with potentially complex intermediate forms. (Edit: Lisp is interpreted, but that just means the translation to binary is happening at runtime instead of compile time.) The resultant assembly is very likely more than a few lines, even with simple 1960s-era compilers / interpreters.
While older hardware and as-yet undiscovered compiler techniques may have limited exactly which features compilers could support in the past, the translation down to imperative assembly (and then binary) has always had to happen to run programs written in high-level languages.
In fact, the amount of computation it took to translate Lisp to assembly in days of yore is part of what gave rise to special Lisp machines, architected explicitly to make running Lisp efficient.
That said, compilers are certainly getting more complex as the field advances, and today's generated assembly is certainly different than it used to be. The number of people who must understand a particular compiler at a deep level is (ideally) a small fraction of the number of people who will write code in the compiler's source language, so compilers are the logical place to house arcane optimizations and complex feature implementations.
If you are interested in learning more about compiler guts, I'd look around for a compiler geared towards students rather than a compiler used to create production binaries. (Sorry, I don't know of any "teaching compilers" off the top of my head.) Or, grab a copy of the dragon book and try building your own! :D
Lexers and parsers.
Yes, lexical analysis and parsing are the first stages of compiling programs - and if you're only interested in syntactical correctness, the further stages are unnecessary. Coursera has a course on compilers you might find interesting, and the Dragon Book is widely regarded as a classic reference on them (though I must admit that I haven't read it myself).
As for regular expressions that are mentioned in other comments - they aren't powerful enough to parse mathematical expressions or computer programs. You can read on formal language theory if you're interested in that; to put it simply, regular expressions are incapable of counting how many times some token appeared (i.e. they can't match stuff like braces and are thus incapable of parsing structures that can be nested arbitrarily deeply, like subexpressions in a mathematical equation).
The general answer is to read as many books on C++ as you can find. The definitive list is in the sidebar. As for linking and loading, there is a severe dearth of books on the subject. I recently finished Linkers and Loaders which provides a detailed description of several different object formats and linker strategies.
No, I can't. Have you even peaked inside a book on compilers? RMS is not just a unique person with a set of original ideas on software, he is a a fucking genious, having completed the most rigorous math course in the country. The fact that he casually admits not having installed GNU/Linux, doesn't have any bearing on his abilities or accomplishments. Of course GCC took off, but compilers aren't trivial creations.