on master help sign in
Carve declaration parser into chunks
commit0cb7175ce934c4832017768005be14d4cdfd229a authorEvan Czaplicki <info@elm-lang.org> dateTue 7 Apr 2015, 11:11 (12 years ago) parentb7c2f90
1 file changed+8
src/Parse/Declaration.hs+8
src/Parse/Declaration.hs+8
@@ -15,11 +15,15 @@ declaration =
1515 typeDecl <|> infixDecl <|> port <|> definition
1616
1717
18+-- TYPE ANNOTATIONS and DEFINITIONS
19+
1820definition :: IParser D.SourceDecl
1921definition =
2022 D.Definition <$> (Expr.typeAnnotation <|> Expr.definition)
2123
2224
25+-- TYPE ALIAS and UNION TYPES
26+
2327typeDecl :: IParser D.SourceDecl
2428typeDecl =
2529 do try (reserved "type") <?> "type declaration"
@@ -40,6 +44,8 @@ typeDecl =
4044 return $ D.Datatype name args tcs
4145
4246
47+-- INFIX
48+
4349infixDecl :: IParser D.SourceDecl
4450infixDecl =
4551 do assoc <-
@@ -54,6 +60,8 @@ infixDecl =
5460 D.Fixity assoc (read [n]) <$> anyOp
5561
5662
63+-- PORT
64+
5765port :: IParser D.SourceDecl
5866port =
5967 do try (reserved "port")