This commit is contained in:
crumbtoo
2024-01-10 10:46:53 -07:00
parent 4b44f57066
commit 1d43c1d304

View File

@@ -65,10 +65,12 @@ blockComment = L.skipBlockCommentNested "{-" "-}" $> "<unimpl>"
decl :: Parser PartialDecl' decl :: Parser PartialDecl'
decl = choice decl = choice
[ funD -- declarations that begin with a keyword before those beginning with an
, tySigD -- arbitrary name
[ infixD
, dataD , dataD
, infixD , funD
, tySigD
] ]
funD :: Parser PartialDecl' funD :: Parser PartialDecl'
@@ -150,26 +152,28 @@ varid = NameVar <$> try (lexeme namevar)
<?> "variable identifier" <?> "variable identifier"
decls :: Parser [PartialDecl'] decls :: Parser [PartialDecl']
decls = L.indentBlock scn p where decls = do
p = do
a <- "wtf"
pure (L.IndentSome (Just pos1) pure decl)
t :: Parser [PartialDecl']
t = do
space space
i <- L.indentLevel i <- L.indentLevel
let indentGuard = L.indentGuard scn EQ i let indentGuard = L.indentGuard scn EQ i
-- indentGuard *> decl *> eol *> indentGuard *> decl -- indentGuard *> decl *> eol *> indentGuard *> decl
rec ds <- indentGuard *> decl <|> eof many $ indentGuard *> decl
many $ indentGuard *> decl <* (eol <|> eof) -- many $ indentGuard *> decl <* (eol <|> eof)
namevar :: Parser Name namevar :: Parser Name
namevar = word namevar = word
& withPredicate (`notElem` ["where"]) empty & withPredicate (`notElem` keywords) empty
where word = T.pack <$> where word = T.pack <$>
liftA2 (:) (satisfy isLower) (many $ satisfy isNameTail) liftA2 (:) (satisfy isLower) (many $ satisfy isNameTail)
keywords :: (IsString a) => [a]
keywords =
[ "where"
, "infix"
, "infixr"
, "infixl"
]
isNameTail :: Char -> Bool isNameTail :: Char -> Bool
isNameTail c = isAlphaNum c isNameTail c = isAlphaNum c
|| c == '\'' || c == '\''
@@ -217,7 +221,8 @@ infixD = do
f (Just x) = registerCustomFailure RlpParErrDuplicateInfixD f (Just x) = registerCustomFailure RlpParErrDuplicateInfixD
$> Just x $> Just x
tySigD = undefined tySigD :: Parser (Decl' e)
tySigD = undefined -- TySigD <$> (flexeme)
dataD :: Parser (Decl' e) dataD :: Parser (Decl' e)
dataD = DataD <$> (lexeme "data" *> conid) <*> many typaram dataD = DataD <$> (lexeme "data" *> conid) <*> many typaram