Skip to content

Commit

Permalink
Cleanup warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
natefaubion committed Aug 11, 2021
1 parent 8be9edf commit 0b2410c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/PureScript/CST/Errors.purs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ printTokenError = case _ of
"hole ?" <> name
TokChar raw _ ->
"char literal '" <> raw <> "'"
TokString raw _ ->
TokString _ _ ->
"string literal"
TokRawString raw ->
TokRawString _ ->
"raw string literal"
TokInt raw _ ->
"int literal " <> raw
Expand Down
2 changes: 1 addition & 1 deletion src/PureScript/CST/Layout.purs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ insertLayout src@{ range, value: tok } nextPos stack =
pushStack lytPos lyt (Tuple stk acc) =
Tuple (Tuple lytPos lyt : stk) acc

popStack p state@(Tuple (Tuple _ lyt : stk') acc)
popStack p (Tuple (Tuple _ lyt : stk') acc)
| p lyt = Tuple stk' acc
popStack _ state = state

Expand Down
26 changes: 1 addition & 25 deletions src/PureScript/CST/Lexer.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Data.Int as Int
import Data.Lazy as Lazy
import Data.List (List(..), (:))
import Data.Maybe (Maybe(..), isNothing, maybe)
import Data.Newtype (un, unwrap)
import Data.Newtype (unwrap)
import Data.Number as Number
import Data.String (Pattern(..), Replacement(..))
import Data.String as String
Expand Down Expand Up @@ -111,13 +111,6 @@ string mkErr match = Lex \str ->
else
LexFail (\_ -> mkErr (mkUnexpected str)) str

string' :: forall a e. (String -> e) -> a -> String -> Lex (Unit -> e) a
string' mkErr res match = Lex \str ->
if SCU.take (SCU.length match) str == match then
LexSucc res (SCU.drop (SCU.length match) str)
else
LexFail (\_ -> mkErr (mkUnexpected str)) str

char :: forall e. (String -> e) -> Char -> Lex (Unit -> e) Char
char mkErr match = Lex \str ->
if SCU.singleton match == SCU.take 1 str then
Expand Down Expand Up @@ -151,11 +144,6 @@ satisfy mkErr p = Lex \str ->
_ ->
LexFail (\_ -> mkErr (mkUnexpected str)) str

takeWhile :: forall e. (Char -> Boolean) -> Lex e String
takeWhile p = Lex \str -> do
let res = SCU.takeWhile p str
LexSucc res (SCU.drop (SCU.length res) str)

many :: forall e a. Lex e a -> Lex e (Array a)
many (Lex k) = Lex \str -> do
let
Expand Down Expand Up @@ -223,15 +211,6 @@ lexWithState = init
<*> trailingComments
<*> leadingComments

bump :: Int -> Int -> SourcePos -> SourcePos
bump lines cols pos
| lines == 0 =
pos { column = pos.column + cols }
| otherwise =
{ line: pos.line + lines
, column: cols
}

bumpToken :: SourcePos -> Token -> SourcePos
bumpToken pos@{ line, column } = case _ of
TokLeftParen ->
Expand Down Expand Up @@ -671,6 +650,3 @@ toModuleName :: Array String -> Maybe ModuleName
toModuleName = case _ of
[] -> Nothing
mn -> Just $ ModuleName $ String.joinWith "." mn

moduleNameLength :: Maybe ModuleName -> Int
moduleNameLength = maybe 0 (String.length <<< un ModuleName)
7 changes: 2 additions & 5 deletions src/PureScript/CST/Parser.purs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ parens = wrapped tokLeftParen tokRightParen
braces :: forall a. Parser a -> Parser (Wrapped a)
braces = wrapped tokLeftBrace tokRightBrace

squares :: forall a. Parser a -> Parser (Wrapped a)
squares = wrapped tokLeftSquare tokRightSquare

layoutNonEmpty :: forall a. Parser a -> Parser (NonEmptyArray a)
layoutNonEmpty valueParser = ado
head <- tokLayoutStart *> valueParser
Expand Down Expand Up @@ -1164,11 +1161,11 @@ recoverTokensWhile p initStream = go [] initStream

go :: Array SourceToken -> TokenStream -> Recovery (Array SourceToken)
go acc stream = case TokenStream.step stream of
TokenError errPos err errStream _ ->
TokenError errPos _ _ _ ->
Recovery acc errPos stream
TokenEOF eofPos _ ->
Recovery acc eofPos stream
TokenCons tok nextPos nextStream _ ->
TokenCons tok _ nextStream _ ->
if p tok indent then
go (Array.snoc acc tok) nextStream
else
Expand Down
6 changes: 3 additions & 3 deletions src/PureScript/CST/Parser/Monad.purs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ runParser' = \state parser ->
go (StkLookAhead stack state) state a
Bind p binds ->
go (StkBinds stack binds) state p
p@(Pure a) ->
Pure a ->
case unwindSucc a state stack of
SuccBinds prevStack prevState queue ->
case unconsView queue of
Expand All @@ -264,7 +264,7 @@ runParser' = \state parser ->
go (StkBinds prevStack nextQueue) prevState (k a)
SuccStop res ->
res
p@(Fail errPos err) ->
Fail errPos err ->
case unwindFail err errPos state stack of
FailAlt prevStack prevState prev ->
go prevStack prevState prev
Expand Down Expand Up @@ -299,7 +299,7 @@ runParser' = \state parser ->
iter acc state' = case runParser' (state' { consumed = false }) p of
ParseSucc a state'' ->
iter (step acc a) state''
res@(ParseFail err errPos state'' _)
ParseFail err errPos state'' _
| state''.consumed ->
Tuple state'' (Fail errPos err)
| otherwise ->
Expand Down

0 comments on commit 0b2410c

Please sign in to comment.