Skip to content

Commit

Permalink
compiler: trim path in source pos
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilin Chen authored and Zilin Chen committed Mar 6, 2018
1 parent b4ba331 commit 658dee2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions cogent/src/Cogent/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ import Data.Maybe
import qualified Data.Set as S
import Text.Parsec.Char
import Text.Parsec.Combinator
import Text.Parsec.Error
import Text.Parsec.Expr
import Text.Parsec.Language
import Text.Parsec.Pos
import Text.Parsec.Prim
import Text.Parsec.String (parseFromFile)
-- import Text.Parsec.String (parseFromFile)
import qualified Text.Parsec.Token as T
import System.Directory
import System.FilePath
Expand Down Expand Up @@ -360,7 +361,6 @@ loadTransitive' r fp paths ro = do
Right defs -> do
defs' <- mapM (flip transitive fpdir) defs
return $ fmap (second (pragmas ++) . mconcat) . sequence $ defs'

where
transitive :: (SourcePos, DocString, TopLevel LocType VarName LocExpr)
-> FilePath
Expand Down Expand Up @@ -391,3 +391,8 @@ tygen = do
ty <- monotype -- NOTE: this syntax is because of the `avoidInitial`s in `monotype` function / zilinc
return (ty,cty)

parseFromFile :: Parser a () -> FilePath -> IO (Either ParseError a)
parseFromFile p fname = do
input <- readFile fname
return $ runP p () (takeFileName fname) input

1 change: 0 additions & 1 deletion cogent/src/Cogent/PrettyPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Cogent.TypeCheck.Base
import Cogent.TypeCheck.Subst

import Control.Arrow (second)
import Data.Either (either)
import Data.Function ((&))
import Data.IntMap as I (IntMap, toList, lookup)
import Data.List(nub)
Expand Down

0 comments on commit 658dee2

Please sign in to comment.