Skip to content

Commit 6ca6a7a

Browse files
committed
Start lexer module
1 parent 4bcac80 commit 6ca6a7a

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

rust_src/lex.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//! The notcc lexer
2+
pub enum TokenKind {
3+
// Keywords come first so they get precedence in parsing over things
4+
// like IDENTIFIER. This works as integer keys used in PATTERN_MAP
5+
// below are iterated in ascending numeric order.
6+
KwInt,
7+
KwVoid,
8+
KwReturn,
9+
KwIf,
10+
KwElse,
11+
LeftParen,
12+
RightParen,
13+
LeftCurly,
14+
RightCurly,
15+
LeftSquare,
16+
RightSquare,
17+
Semicolon,
18+
Identifier,
19+
IntConstant,
20+
UnaryBitwiseComplement,
21+
LogicalNot,
22+
Decrement,
23+
Minus,
24+
Plus,
25+
Times,
26+
Divide,
27+
Remainder,
28+
And,
29+
Or,
30+
Less,
31+
LessEq,
32+
Greater,
33+
GreaterEq,
34+
Equal,
35+
NotEqual,
36+
Assign,
37+
Question,
38+
Colon,
39+
}

rust_src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ pub mod error;
44
pub use driver::{arg_parser::Cli, driver_main, driver_main_cli};
55

66
mod driver;
7+
mod lex;

0 commit comments

Comments
 (0)