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:
parent
cf4f35f997
commit
e7dfb662ed
1 changed files with 12 additions and 13 deletions
|
|
@ -384,11 +384,10 @@ literal =
|
|||
pure $ TemplateTail $ fromText $ mconcat $ map toText $ contents
|
||||
template_char :: Parser s m s
|
||||
template_char =
|
||||
fromText . toText
|
||||
<$> choice
|
||||
[ try (string "$" <* (notFollowedBy $ char '{')),
|
||||
choice
|
||||
[ try ((fromText . toText <$> string "$") <* (notFollowedBy $ char '{')),
|
||||
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
|
||||
do
|
||||
notFollowedBy (choice [void linebreak, void $ char '`', void $ char '\\', void $ char '$'])
|
||||
|
|
@ -446,13 +445,13 @@ fslash_handler = do
|
|||
rem_chars <- many reg_rem_char
|
||||
let body = fromString (first_char : rem_chars)
|
||||
char '/'
|
||||
flags <- fromString $ tokensToChunk (Proxy :: Proxy s) <$> many letterChar
|
||||
flags <- fromString <$> many letterChar
|
||||
pure $ Literal $ Regex {body, flags}
|
||||
reg_first_char :: Parser s m 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
|
||||
-- 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 = anySingleBut '/'
|
||||
division_assign :: Parser s m (Token s)
|
||||
|
|
|
|||
Loading…
Reference in a new issue