Skip to content

Commit 3abbcb5

Browse files
authored
Update README.md
1 parent 896cc3c commit 3abbcb5

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
11
### Writing a compiler from scratch
22

3-
Yes
3+
Parts of a compiler:
4+
- Lexer
5+
- Parser
6+
- Semantic Analysis
7+
- IR Generation
8+
- Optimization Passes
9+
- Code Generation
10+
11+
I might skip the backend and make this an interpreter (easier?)
12+
13+
Current progress:
14+
15+
Lexer: Done
16+
Consider a program as a long string, loop through it token by token, and assign each token.
17+
Each Token can be:
18+
``` rust
19+
pub enum Token {
20+
// Delimiters
21+
Comma,
22+
LeftParen,
23+
RightParen,
24+
LeftBrace,
25+
RightBrace,
26+
SemiColon,
27+
DoubleQuote,
28+
// Operators
29+
Add,
30+
Sub,
31+
Mul,
32+
Div,
33+
Mod,
34+
NotEqual,
35+
EqualEqual,
36+
Greater,
37+
GreaterEqual,
38+
Less,
39+
LessEqual,
40+
Equal,
41+
Not,
42+
Or,
43+
And,
44+
// Literals
45+
Number(i32),
46+
Boolean(bool),
47+
Identifier(String),
48+
StringLiteral(String),
49+
// Keywords
50+
Func,
51+
Main,
52+
If,
53+
Else,
54+
For,
55+
While,
56+
Let,
57+
Return,
58+
Print,
59+
}
60+
```

0 commit comments

Comments
 (0)