Mixfix operators

This commit is contained in:
2024-11-09 22:11:58 -08:00
parent 6abd97ee85
commit 91bb79a998
13 changed files with 250 additions and 44 deletions

View File

@@ -8,11 +8,14 @@ import Lib.Common
keywords : List String
keywords = ["let", "in", "where", "case", "of", "data", "U", "do",
"ptype", "pfunc", "module", "infixl", "infixr", "infix",
"", "forall", ".",
"", "forall",
"->", "", ":", "=>", ":=", "=", "<-", "\\", "_"]
checkKW : String -> Token Kind
checkKW s = if elem s keywords then Tok Keyword s else Tok Ident s
checkKW s =
if s /= "_" && elem '_' (unpack s) then Tok MixFix s else
if elem s keywords then Tok Keyword s
else Tok Ident s
checkUKW : String -> Token Kind
checkUKW s = if elem s keywords then Tok Keyword s else Tok UIdent s
@@ -54,7 +57,7 @@ rawTokens
-- for now, our lambda slash is singleton
<|> match (singleton) (Tok Symbol)
-- TODO Drop MixFix token type when we support if_then_else_
<|> match (exact "_" <+> (some opMiddle) <+> exact "_") (Tok MixFix)
<|> match (exact "_,_" <|> exact "_._") (Tok MixFix)
-- REVIEW - expect non-alpha after?
<|> match (some digit) (Tok Number)
-- for module names and maybe type constructors