ref: 5d02ec08904e975cf4b0530bf779cec838622ea9
parent: 534875dc5a17ca4ccf213ec1d699060928a17033
author: Lennart Augustsson <lennart@augustsson.net>
date: Fri Sep 15 06:03:58 EDT 2023
Parse infix.
--- a/src/MicroHs/Parse.hs
+++ b/src/MicroHs/Parse.hs
@@ -235,6 +235,12 @@
<|> Sign <$> (pLIdentSym <* pSymbol "::") <*> pTypeScheme
<|> Import <$> (pKeyword "import" *> pImportSpec)
<|> ForImp <$> (pKeyword "foreign" *> pKeyword "import" *> pKeyword "ccall" *> pString) <*> pLIdent <*> (pSymbol "::" *> pType)
+ <|> Infix <$> (pair <$> pAssoc <*> pPrec) <*> esepBy1 pOper (pSpec ',')
+ where
+ pAssoc = (AssocLeft <$ pKeyword "infixl") <|> (AssocRight <$ pKeyword "infixr") <|> (AssocNone <$ pKeyword "infix")
+ dig (TInt _ i) | 0 <= i && i <= 9 = Just i
+ dig _ = Nothing
+ pPrec = satisfyM "digit" dig
pLHS :: P LHS
pLHS = pair <$> pUIdentSym <*> many pIdKind
--
⑨