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,17 +384,16 @@ 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 (fromText . toText <$> ((optional $ char '\\') *> (eol))),
|
||||||
try ((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 '$'])
|
c <- source_char
|
||||||
c <- source_char
|
pure $ fromString $ c : []
|
||||||
pure $ fromString $ c : []
|
]
|
||||||
]
|
|
||||||
source_char = anySingle
|
source_char = anySingle
|
||||||
escape_seq = do
|
escape_seq = do
|
||||||
char '\\'
|
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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue