Do you remember the exercises you did as a kid when you diagrammed a sentence? You would find the nouns and the verbs, etc and use the structure of the sentence to build an understanding of it?
Compilers do the same thing. It takes the source files you give it, turns it into words and symbols, then diagrams them into a structure called an abstract syntax tree. From the AST, the compiler can figure out what order it needs to do stuff in, what parts are dependent on each other, and what the code actually means. Once it knows that, it can transform the program into machine code, which is the language your computer actually understands.
Machine code is a string of binary values, 1s and 0s. Each instructions is a specific string of binary values which control the machines inside the CPU.
Latest Answers