h1: make ' and ? only allowed as suffixes in identifiers

This commit is contained in:
りき萌 2025-09-02 20:30:47 +02:00
parent e31dde1048
commit 69cc34d07e

View file

@ -57,7 +57,11 @@ fn one_or_two(l: &mut Lexer<'_>, kind1: TokenKind, c2: char, kind2: TokenKind) -
} }
fn is_ident_char(c: char) -> bool { fn is_ident_char(c: char) -> bool {
matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '_' | '\'' | '?') matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '_')
}
fn is_ident_extra_char(c: char) -> bool {
matches!(c, '\'' | '?')
} }
fn ident(l: &mut Lexer<'_>) -> TokenKind { fn ident(l: &mut Lexer<'_>) -> TokenKind {
@ -65,6 +69,9 @@ fn ident(l: &mut Lexer<'_>) -> TokenKind {
while is_ident_char(l.current()) { while is_ident_char(l.current()) {
l.advance(); l.advance();
} }
while is_ident_extra_char(l.current()) {
l.advance();
}
let end = l.position; let end = l.position;
match Span::new(start, end).slice(l.input) { match Span::new(start, end).slice(l.input) {