Show me all steps that compiler does Lexical Analyses, Token Tree, and code generation for simple Hello world program in C.
Show me all steps that compiler does Lexical Analyses, Token Tree, and code generation for simple Hello world program in C.

Let's break down the process of compiling a simple "Hello, World!" program in C, focusing on the lexical analysis, token tree, and code generation stages.

1. **Source Code**:

```c
#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}
```

2. **Lexical Analysis**:

The compiler begins by reading the source code and breaking it down into individual tokens. These tokens are the smallest units of meaning in the program. The compiler identifies keywords, identifiers, literals, operators, and punctuation symbols.

```
#      (Keyword)
"include" (Identifier)
<      (Less than symbol, Punctuation)
stdio.h (String literal, Identifier)
>      (Greater than symbol, Punctuation)

int     (Identifier)
(       (Parenthesis, Punctuation)
main   (Identifier)
)       (Parenthesis, Punctuation)
{       (Curly brace, Punctuation)

printf (Identifier)
(       (Parenthesis, Punctuation)
"Hello, World!" (String literal)
,       (Comma, Punctuation)
"n"     (String literal)
)       (Parent
The compiler begins by performing lexical analysis on the source code. This process breaks down the source code into individual words and assigns each word a unique token. The token tree is then constructed, with each node in the tree representing a different type of token. The compiler then performs various operations on the token tree, such as determining the type of the token and looking up rules in the grammar for that type of token. Finally, the code generator takes the information from the token tree and generates the actual machine code that the program will be executed as. For a simple hello world program in C, this process would look like this:

1. Lexical Analysis - Tokenizes the source code and assigns each word a unique token.
2. Token Tree - Constructs a tree structure with each node representing a different type of token.
3. Grammar Rules - Applies the grammar rules for each token type.
4. Code Generation - Generates the actual machine code based on the information from the token tree.
5. Assembly - Compiles the machine code into assembly language.
6. Linking - Links the assembly language code into a single executable program.