fix type errors in javascript tokenizer

Fixed three type errors preventing compilation:
- template_char: properly convert Tokens s to s for string literals and eol
- regex_literal: correctly apply fromString to parser result, not parser itself
- reg_first_char: use explicit list notation to resolve noneOf ambiguity

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Pagwin 2026-01-31 15:09:45 -05:00
parent cf4f35f997
commit e7dfb662ed
No known key found for this signature in database
GPG key ID: 81137023740CA260

View file

@ -384,11 +384,10 @@ literal =
pure $ TemplateTail $ fromText $ mconcat $ map toText $ contents pure $ TemplateTail $ fromText $ mconcat $ map toText $ contents
template_char :: Parser s m s template_char :: Parser s m s
template_char = template_char =
fromText . toText choice
<$> choice [ try ((fromText . toText <$> string "$") <* (notFollowedBy $ char '{')),
[ try (string "$" <* (notFollowedBy $ char '{')),
try escape_seq, try escape_seq,
try ((optional $ char '\\') *> (eol)), try (fromText . toText <$> ((optional $ char '\\') *> (eol))),
-- I'm sure this is doable without do but do makes it much easier -- I'm sure this is doable without do but do makes it much easier
do do
notFollowedBy (choice [void linebreak, void $ char '`', void $ char '\\', void $ char '$']) notFollowedBy (choice [void linebreak, void $ char '`', void $ char '\\', void $ char '$'])
@ -446,13 +445,13 @@ fslash_handler = do
rem_chars <- many reg_rem_char rem_chars <- many reg_rem_char
let body = fromString (first_char : rem_chars) let body = fromString (first_char : rem_chars)
char '/' char '/'
flags <- fromString $ tokensToChunk (Proxy :: Proxy s) <$> many letterChar flags <- fromString <$> many letterChar
pure $ Literal $ Regex {body, flags} pure $ Literal $ Regex {body, flags}
reg_first_char :: Parser s m Char reg_first_char :: Parser s m Char
-- ecmascript specification name lied to me, it can be more than one char >:( -- ecmascript specification name lied to me, it can be more than one char >:(
-- to clarify this is technically wrong but I don't care because I don't want to rewrite -- to clarify this is technically wrong but I don't care because I don't want to rewrite
-- other code due to ecmascript standard using bad names -- other code due to ecmascript standard using bad names
reg_first_char = noneOf "*/" reg_first_char = noneOf ['*', '/']
reg_rem_char :: Parser s m Char reg_rem_char :: Parser s m Char
reg_rem_char = anySingleBut '/' reg_rem_char = anySingleBut '/'
division_assign :: Parser s m (Token s) division_assign :: Parser s m (Token s)