Skip to content

Commit

Permalink
Primitive types in tokenizer and parser
Browse files Browse the repository at this point in the history
  • Loading branch information
N00byEdge committed Oct 8, 2023
1 parent 22d1faf commit 7389326
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions selfhost/parser.n
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const NodeType = enum(u8) {
identifier,
int_literal,
string_literal,
primitive,

// if there is no token (-1), it is a file top-level struct
// otherwise, token is the struct/enum/union token
Expand Down Expand Up @@ -249,6 +250,9 @@ fn parse_primary_expression(context: *ParserContext, require: bool, precedence:
}
return context.add_advance(.identifier);
}
else if(.bool_keyword <= p && p <= .i64) {
return context.add_advance(.primitive);
}
else if(p == .int_literal) {
return context.add_advance(.int_literal);
}
Expand Down
9 changes: 9 additions & 0 deletions selfhost/tokenizer.n
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ const TokenType = enum(u8) {
noreturn_keyword,
anyopaque_keyword,

u8,
u16,
u32,
u64,
i8,
i16,
i32,
i64,

// Single- or multi-character tokens
@".",
@"..",
Expand Down

0 comments on commit 7389326

Please sign in to comment.