Skip to content

Commit

Permalink
Allowing capitalized type names
Browse files Browse the repository at this point in the history
  • Loading branch information
Divy1211 committed Dec 13, 2024
1 parent 2b633ff commit a07cc98
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/parsing/lexer/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub fn keyword<'src>() -> impl Parser<
'src, &'src str, Token, extra::Err<Rich<'src, char, Span>>
> {
text::ascii::ident().map(|ident| match ident {
"vector" => Token::Vector,
"include" => Token::Include,
"switch" => Token::Switch,
"case" => Token::Case,
Expand All @@ -24,10 +23,6 @@ pub fn keyword<'src>() -> impl Parser<
"dbg" => Token::Dbg,
"return" => Token::Return,
"void" => Token::Void,
"int" => Token::Int,
"bool" => Token::Bool,
"float" => Token::Float,
"string" => Token::String,
"const" => Token::Const,
"priority" => Token::Priority,
"minInterval" => Token::MinInterval,
Expand All @@ -46,6 +41,12 @@ pub fn keyword<'src>() -> impl Parser<
"runImmediately" => Token::RunImmediately,
"mutable" => Token::Mutable,
"class" => Token::Class,
_ => Token::Identifier(Identifier::new(ident))

_ if ident.eq_ignore_ascii_case("int") => Token::Int, // yES
_ if ident.eq_ignore_ascii_case("bool") => Token::Bool,
_ if ident.eq_ignore_ascii_case("float") => Token::Float,
_ if ident.eq_ignore_ascii_case("string") => Token::String,
_ if ident.eq_ignore_ascii_case("vector") => Token::Vector,
_ => Token::Identifier(Identifier::new(ident))
})
}

0 comments on commit a07cc98

Please sign in to comment.