From ed60ec8b3225dc3c36a7fb8791916120be5402e9 Mon Sep 17 00:00:00 2001 From: crumbtoo Date: Wed, 10 Jan 2024 10:46:53 -0700 Subject: [PATCH] aaaaa --- src/RLP/Parse/Decls.hs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/RLP/Parse/Decls.hs b/src/RLP/Parse/Decls.hs index 9d4a911..201316b 100644 --- a/src/RLP/Parse/Decls.hs +++ b/src/RLP/Parse/Decls.hs @@ -65,10 +65,12 @@ blockComment = L.skipBlockCommentNested "{-" "-}" $> "" decl :: Parser PartialDecl' decl = choice - [ funD - , tySigD + -- declarations that begin with a keyword before those beginning with an + -- arbitrary name + [ infixD , dataD - , infixD + , funD + , tySigD ] funD :: Parser PartialDecl' @@ -150,26 +152,28 @@ varid = NameVar <$> try (lexeme namevar) "variable identifier" decls :: Parser [PartialDecl'] -decls = L.indentBlock scn p where - p = do - a <- "wtf" - pure (L.IndentSome (Just pos1) pure decl) - -t :: Parser [PartialDecl'] -t = do +decls = do space i <- L.indentLevel let indentGuard = L.indentGuard scn EQ i -- indentGuard *> decl *> eol *> indentGuard *> decl - rec ds <- indentGuard *> decl <|> eof - many $ indentGuard *> decl <* (eol <|> eof) + many $ indentGuard *> decl + -- many $ indentGuard *> decl <* (eol <|> eof) namevar :: Parser Name namevar = word - & withPredicate (`notElem` ["where"]) empty + & withPredicate (`notElem` keywords) empty where word = T.pack <$> liftA2 (:) (satisfy isLower) (many $ satisfy isNameTail) +keywords :: (IsString a) => [a] +keywords = + [ "where" + , "infix" + , "infixr" + , "infixl" + ] + isNameTail :: Char -> Bool isNameTail c = isAlphaNum c || c == '\'' @@ -217,7 +221,8 @@ infixD = do f (Just x) = registerCustomFailure RlpParErrDuplicateInfixD $> Just x -tySigD = undefined +tySigD :: Parser (Decl' e) +tySigD = undefined -- TySigD <$> (flexeme) dataD :: Parser (Decl' e) dataD = DataD <$> (lexeme "data" *> conid) <*> many typaram