Skip to content

Commit

Permalink
allKeywords: use tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyYakeley committed Sep 11, 2024
1 parent e04e613 commit 5727141
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions Pinafore/pinafore-syntax/lib/Pinafore/Syntax/Parse/Token.hs
Original file line number Diff line number Diff line change
Expand Up @@ -357,34 +357,29 @@ checkKeyword "debug"
| debugSyntaxINTERNAL = return $ MkSomeOf TokDebug ()
checkKeyword _ = Nothing

allKeywords :: [(Text, Text)]
allKeywords =
[ ("fn", "keyword.control.pinafore")
, ("rec", "keyword.other.pinafore")
, ("let", "keyword.other.pinafore")
, ("imply", "keyword.other.pinafore")
, ("ap", "keyword.control.pinafore")
, ("do", "keyword.control.pinafore")
, ("if", "keyword.control.pinafore")
, ("then", "keyword.control.pinafore")
, ("else", "keyword.control.pinafore")
, ("type", "keyword.declaration.pinafore")
, ("datatype", "keyword.declaration.pinafore")
, ("entitytype", "keyword.declaration.pinafore")
, ("predicatetype", "keyword.declaration.pinafore")
, ("subtype", "keyword.declaration.pinafore")
, ("trustme", "keyword.declaration.pinafore")
, ("storable", "keyword.declaration.pinafore")
, ("module", "keyword.declaration.pinafore")
, ("expose", "keyword.declaration.pinafore")
, ("import", "keyword.declaration.pinafore")
, ("as", "keyword.other.pinafore")
, ("except", "keyword.other.pinafore")
, ("namespace", "keyword.declaration.pinafore")
, ("docsec", "keyword.declaration.pinafore")
, ("with", "keyword.declaration.pinafore")
keywordClasses :: [(Text, [Token ()])]
keywordClasses =
[ ("keyword.control.pinafore", [TokFn, TokAp, TokDo, TokIf, TokThen, TokElse])
, ( "keyword.declaration.pinafore"
, [ TokType
, TokDataType
, TokEntityType
, TokPredicateType
, TokSubtype
, TokTrustMe
, TokStorable
, TokExpose
, TokImport
, TokNamespace
, TokDocSec
, TokWith
])
, ("keyword.other.pinafore", [TokRec, TokLet, TokImply, TokAs, TokExcept])
]

allKeywords :: [(Text, Text)]
allKeywords = mconcat $ fmap (\(tokclass, toks) -> fmap (\tok -> (pack $ show tok, tokclass)) toks) keywordClasses

readTextToken :: Parser (SomeOf Token)
readTextToken = do
(u, name) <- readName
Expand Down

0 comments on commit 5727141

Please sign in to comment.