Skip to content

Commit

Permalink
Fix sed mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Grant Jeffries committed Nov 11, 2019
1 parent 43641af commit 631c422
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions bowtie/src/Bowtie/Surface/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import Bowtie.Lib.OrderedMap (OrderedMap)
import Bowtie.Lib.Prelude hiding (many, some)
import Bowtie.Surface.AST
import Bowtie.Type.Parse
(Parser, ParserErrorBundle, lexeme, lowerIbindingParser, parseTest,
spacesOrNewlines, symbol, upperIbindingParser)
(Parser, ParserErrorBundle, lexeme, lowerIdParser, parseTest,
spacesOrNewlines, symbol, upperIdParser)
import Control.Applicative.Combinators.NonEmpty
import Text.Megaparsec hiding (parse, parseTest, some)

Expand Down Expand Up @@ -99,7 +99,7 @@ bindingParser = do
bindingBodyParser :: Parser (Id, Expr)
bindingBodyParser = do
pos <- Lexer.indentLevel
i <- lexeme lowerIbindingParser
i <- lexeme lowerIdParser
symbol "="
_ <- Lexer.indentGuard spacesOrNewlines GT pos
e <- exprParser
Expand All @@ -121,7 +121,7 @@ lamParser :: Parser Expr
lamParser = do
pos <- Lexer.indentLevel
symbol "\\"
id <- lexeme lowerIbindingParser
id <- lexeme lowerIdParser
mType <- optional annotationParser
symbol "."
_ <- Lexer.indentGuard spacesOrNewlines GT pos
Expand Down Expand Up @@ -186,8 +186,8 @@ caseParser =
altParser :: Parser Alt
altParser = do
pos <- Lexer.indentLevel
i <- lexeme upperIbindingParser
ids <- many (lexeme lowerIbindingParser)
i <- lexeme upperIdParser
ids <- many (lexeme lowerIdParser)
symbol "->"
_ <- Lexer.indentGuard spacesOrNewlines GT pos
e <- exprParser
Expand Down Expand Up @@ -220,11 +220,11 @@ itemParser =

varParser :: Parser Expr
varParser =
fmap Var (lexeme lowerIbindingParser)
fmap Var (lexeme lowerIdParser)

conParser :: Parser Expr
conParser =
fmap Construct (lexeme upperIbindingParser)
fmap Construct (lexeme upperIdParser)

-- |
-- >>> parseTest intParser "1"
Expand Down
28 changes: 14 additions & 14 deletions bowtie/src/Bowtie/Type/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module Bowtie.Type.Parse
, typeDeclarationParser
, typeSignatureParser
, typeParser
, lowerIbindingParser
, upperIbindingParser
, lowerIdParser
, upperIdParser

-- | Helpers
, lexeme
Expand Down Expand Up @@ -63,8 +63,8 @@ typeDeclarationParser = do
-- parser started with Break it would actually have to be
-- @try (toss Break)@ so they wouldn't step on each other's toes.
symbol "type"
typeId <- lexeme upperIbindingParser
typeArgs <- many (lexeme lowerIbindingParser)
typeId <- lexeme upperIdParser
typeArgs <- many (lexeme lowerIdParser)
symbol "="
constructors <- constructorParser `sepBy` symbol "|"
case OrderedMap.fromList constructors of
Expand All @@ -79,7 +79,7 @@ typeDeclarationParser = do
-- (Id "Bar",[TConstructor (Id "Bool"),TVariable (Id "a")])
constructorParser :: Parser (Id, [Type])
constructorParser = do
id <- lexeme upperIbindingParser
id <- lexeme upperIdParser
args <- many constructorArgParser
pure (id, args)

Expand Down Expand Up @@ -107,7 +107,7 @@ constructorArgParser =
-- (Id "foo",TArrow (TConstructor (Id "Int")) (TVariable (Id "a")))
typeSignatureParser :: Parser (Id, Type)
typeSignatureParser = do
i <- lexeme lowerIbindingParser
i <- lexeme lowerIdParser
symbol ":"
t <- typeParser
pure (i, t)
Expand Down Expand Up @@ -160,18 +160,18 @@ singleTypeParser = do
singleTypeParser' :: Parser Type
singleTypeParser' =
-- TODO: a good label
fmap TVariable (lexeme lowerIbindingParser)
<|> fmap TConstructor (lexeme upperIbindingParser)
fmap TVariable (lexeme lowerIdParser)
<|> fmap TConstructor (lexeme upperIdParser)

-- |
-- >>> parseTest lowerIbindingParser "a"
-- >>> parseTest lowerIdParser "a"
-- Id "a"
--
-- When we had a separate lexer this could just be tried after trying
-- to lex keyword tokens like "let" and "in". Now that we don't
-- it needs logic so that it doesn't eat those keywords.
lowerIbindingParser :: Parser Id
lowerIbindingParser = do
lowerIdParser :: Parser Id
lowerIdParser = do
notFollowedBy (keyword *> satisfy (not . validIdChar))
c <- satisfy Char.isLower
rest <- takeWhileP (Just "followup identifier char") validIdChar
Expand All @@ -192,10 +192,10 @@ keywordList =
]

-- |
-- >>> parseTest upperIbindingParser "Unit"
-- >>> parseTest upperIdParser "Unit"
-- Id "Unit"
upperIbindingParser :: Parser Id
upperIbindingParser = do
upperIdParser :: Parser Id
upperIdParser = do
c <- satisfy Char.isUpper
rest <- takeWhileP (Just "followup identifier char") validIdChar
pure (Id (Text.cons c rest))
Expand Down

0 comments on commit 631c422

Please sign in to comment.