Skip to content

Commit 572daf2

Browse files
committed
polish parser
1 parent b7802f3 commit 572daf2

File tree

5 files changed

+236
-226
lines changed

5 files changed

+236
-226
lines changed

src/parser/common.zig

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,23 @@ pub const ParserCommon = struct {
2020
};
2121
}
2222

23-
/// Helper function to create statement SourceSpan from Token
24-
pub fn makeStmtSpan(token: Token) ast.SourceSpan {
25-
return ast.SourceSpan{
26-
.file_id = 0,
27-
.line = token.line,
28-
.column = token.column,
29-
.length = @intCast(token.lexeme.len),
30-
.byte_offset = token.range.start_offset,
31-
.lexeme = token.lexeme,
32-
};
33-
}
34-
3523
/// Check if a keyword can be used as an identifier in certain contexts
3624
pub fn isKeywordThatCanBeIdentifier(token_type: lexer.TokenType) bool {
3725
return switch (token_type) {
3826
.From => true, // 'from' can be used as a parameter name in log declarations
3927
else => false,
4028
};
4129
}
30+
31+
/// Check if token type is a memory region keyword
32+
/// Includes: storage, memory, tstore, const, immutable
33+
pub fn isMemoryRegionKeyword(token_type: lexer.TokenType) bool {
34+
return token_type == .Storage or
35+
token_type == .Memory or
36+
token_type == .Tstore or
37+
token_type == .Const or
38+
token_type == .Immutable;
39+
}
4240
};
4341

4442
/// Unified parser error set shared by all parser components

0 commit comments

Comments
 (0)