Skip to content

Commit

Permalink
Remove original Parsec
Browse files Browse the repository at this point in the history
  • Loading branch information
HuwCampbell committed Apr 3, 2024
1 parent a8a82ba commit d15eddf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 42 deletions.
13 changes: 1 addition & 12 deletions icicle-compiler/icicle.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ library
, lens >= 4.7 && < 5.3
, lifted-async >= 0.9 && < 0.11
, lifted-base == 0.2.*
, megaparsec >= 5.0 && < 8.0
, mmorph >= 1.0
, monad-control == 1.0.*
, mtl == 2.2.*
Expand Down Expand Up @@ -85,16 +86,6 @@ library
, wl-pprint-annotated == 0.1.*
, zenc == 0.1.*

-- Well, it might look very odd that we're using both attoparsec
-- and parsec.
-- The thing is, attoparsec only operates on raw strings, and our source parser
-- for Icicle should operate over tokens.
-- Going over tokens instead of strings simplifies the parser itself and makes everything
-- a bit cleaner.
-- As an added benefit, parsec will give us nicer error messages.
, megaparsec >= 5.0 && < 8.0
, parsec == 3.1.*

ghc-options:
-Wall

Expand Down Expand Up @@ -218,7 +209,6 @@ executable icicle
, optparse-applicative >= 0.14 && < 0.17
, mmorph
, parallel
, parsec
, resourcet
, temporary
, text
Expand Down Expand Up @@ -282,7 +272,6 @@ test-suite test
, geniplate-mirror >= 0.7.2 && < 0.8
, megaparsec
, mtl
, parsec
, pretty-show
, hashable
, hedgehog >= 1.0.2 && < 1.1
Expand Down
12 changes: 2 additions & 10 deletions icicle-source/icicle-source.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ library
, ambiata-p
, ambiata-x-show
, array
, attoparsec >= 0.12 && < 0.14
, aeson >= 0.8 && < 1.5
, ansi-terminal == 0.6.*
, bifunctors >= 4.2 && < 5.6
Expand All @@ -40,6 +41,7 @@ library
, file-embed >= 0.0.9 && < 0.0.16
, hashable
, lens
, megaparsec >= 7.0 && < 8.0
, mmorph >= 1.0
, parser-combinators
, scientific == 0.3.*
Expand All @@ -54,16 +56,6 @@ library
, transformers-either
, validation >= 1 && < 1.2
, vector
-- Well, it might look very odd that we're using both attoparsec
-- and parsec.
-- The thing is, attoparsec only operates on raw strings, and our source parser
-- for Icicle should operate over tokens.
-- Going over tokens instead of strings simplifies the parser itself and makes everything
-- a bit cleaner.
-- As an added benefit, parsec will give us nicer error messages.
, attoparsec >= 0.12 && < 0.14
, megaparsec >= 7.0 && < 8.0
, parsec == 3.1.*

ghc-options:
-Wall
Expand Down
8 changes: 3 additions & 5 deletions icicle-source/src/Icicle/Compiler/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ import Data.String
import Data.Hashable (Hashable)
import qualified Data.Text.Encoding as Text

import qualified Text.ParserCombinators.Parsec as Parsec

import GHC.Generics (Generic)

import P
Expand Down Expand Up @@ -233,7 +231,7 @@ sourceParseQT oid t
= first ErrorSourceParse
$ Parse.parseQueryTop oid t

sourceParseF :: Parsec.SourceName
sourceParseF :: String
-> Text
-> Either Error (Query.Module Sorbet.Range Var)
sourceParseF env t
Expand Down Expand Up @@ -335,7 +333,7 @@ loadedPrelude =
first ErrorSourceParse $ uncurry (Parse.parseModule) Dict.prelude


readIcicleLibraryPure :: Check.CheckOptions -> FilePath -> Parsec.SourceName -> Text -> Either Error (Query.ResolvedModule Sorbet.Range Var)
readIcicleLibraryPure :: Check.CheckOptions -> FilePath -> FilePath -> Text -> Either Error (Query.ResolvedModule Sorbet.Range Var)
readIcicleLibraryPure opts _ source input
= do current <- first ErrorSourceParse $ Parse.parseModule source input
prelude <- loadedPrelude
Expand All @@ -361,7 +359,7 @@ readIcicleLibraryPure opts _ source input
Query.ResolvedModule (Query.moduleName current) [] inputs outputs smooshed


readIcicleLibrary :: Check.CheckOptions -> FilePath -> Parsec.SourceName -> Text -> EitherT Error IO (Query.ResolvedModule Sorbet.Range Var)
readIcicleLibrary :: Check.CheckOptions -> FilePath -> FilePath -> Text -> EitherT Error IO (Query.ResolvedModule Sorbet.Range Var)
readIcicleLibrary opts rootDir source input
= do current <- hoistWith ErrorSourceParse $ Parse.parseModule source input
prelude <- hoistEither loadedPrelude
Expand Down
15 changes: 0 additions & 15 deletions icicle-source/src/Icicle/Sorbet/Position.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ module Icicle.Sorbet.Position (
, Range(..)

, renderPosition
, toParsec
, fromParsec
, fromSourcePos
) where

Expand All @@ -37,7 +35,6 @@ import System.IO (FilePath)

import Text.Megaparsec (Stream(..), PosState (..))
import Text.Megaparsec.Pos (SourcePos(..), mkPos, unPos)
import qualified Text.Parsec.Pos as Parsec

import X.Text.Show (gshowsPrec)

Expand Down Expand Up @@ -166,18 +163,6 @@ fromSourcePos = \case
(fromIntegral $ unPos col)


toParsec :: Position -> Parsec.SourcePos
toParsec = \case
Position file srcLine col ->
Parsec.newPos file srcLine col



fromParsec :: Parsec.SourcePos -> Position
fromParsec =
Position <$> Parsec.sourceName <*> Parsec.sourceLine <*> Parsec.sourceColumn


instance Pretty Position where
pretty =
pretty . renderPosition
Expand Down

0 comments on commit d15eddf

Please sign in to comment.