Permalink
Browse files

Updated supplementals with changes to parseFile and parseURL.

Ignore-this: 9dc80caf530203d76faa46530800b1c0

darcs-hash:20110129212742-1786f-a734c9590dbe2ecd25baca1ffdafad2905d116d6.gz
  • Loading branch information...
1 parent a9cb31a commit 0fca403f13fa2ea4a2cf6e7cf04164d59c25a701 @amccausl committed Jan 29, 2011
@@ -2,7 +2,6 @@ module Main where
import Data.RDF
import Data.RDF.TriplesGraph
-import Text.RDF.RDF4H.ParserUtils (parseFile, parseURL)
import Text.RDF.RDF4H.NTriplesParser (parseNTriplesRDF)
import Text.RDF.RDF4H.TurtleParser (parseTurtleRDF)
import Text.RDF.RDF4H.NTriplesSerializer
@@ -53,16 +52,16 @@ main =
emptyPms = PrefixMappings Map.empty
case (inputFormat, isUri $ s2b inputUri) of
-- we use TriplesGraph in all cases, since it preserves the ordering of triples
- ("turtle", True) -> parseURL (parseTurtleRDF mInputUri docUri) inputUri
+ ("turtle", True) -> parseURL' (parseTurtleRDF mInputUri docUri) inputUri
>>= \(res :: Either ParseFailure TriplesGraph) -> write outputFormat docUri emptyPms res
("turtle", False) -> (if inputUri /= "-"
- then parseFile (parseTurtleRDF mInputUri docUri) inputUri
+ then parseFile' (parseTurtleRDF mInputUri docUri) inputUri
else fmap (parseTurtleRDF mInputUri docUri) B.getContents)
>>= \(res :: Either ParseFailure TriplesGraph) -> write outputFormat docUri emptyPms res
- ("ntriples", True) -> parseURL parseNTriplesRDF inputUri
+ ("ntriples", True) -> parseURL' parseNTriplesRDF inputUri
>>= \(res :: Either ParseFailure TriplesGraph) -> write outputFormat Nothing emptyPms res
("ntriples", False) -> (if inputUri /= "-"
- then parseFile parseNTriplesRDF inputUri
+ then parseFile' parseNTriplesRDF inputUri
else fmap parseNTriplesRDF B.getContents)
>>= \(res :: Either ParseFailure TriplesGraph) -> write outputFormat Nothing emptyPms res
(str , _ ) -> putStrLn ("Invalid format: " ++ str) >> exitFailure
@@ -22,7 +22,6 @@ import Data.RDF
import Data.RDF.Utils()
import Data.RDF.TriplesGraph()
import Data.RDF.MGraph()
-import Text.RDF.RDF4H.ParserUtils (parseFile, parseURL)
import Text.RDF.RDF4H.NTriplesParser (parseNTriplesRDF)
import Text.RDF.RDF4H.TurtleParser (parseTurtleRDF)
import Text.RDF.RDF4H.NTriplesSerializer()
@@ -34,12 +33,12 @@ import Text.RDF.RDF4H.TurtleSerializer()
--
-- This function calls 'error' with an error message if unable to load the file.
loadTurtleFile :: forall rdf. (RDF rdf) => Maybe String -> Maybe String -> String -> IO rdf
-loadTurtleFile baseUrl docUri = _load (parseFile (mkTurtleParser baseUrl docUri))
+loadTurtleFile baseUrl docUri = _load (parseFile' (mkTurtleParser baseUrl docUri))
-- |Load a Turtle file from a URL just like 'loadTurtleFile' does from the local
-- filesystem. See that function for explanation of args, etc.
loadTurtleURL :: forall rdf. (RDF rdf) => Maybe String -> Maybe String -> String -> IO rdf
-loadTurtleURL baseUrl docUri = _load (parseURL (mkTurtleParser baseUrl docUri))
+loadTurtleURL baseUrl docUri = _load (parseURL' (mkTurtleParser baseUrl docUri))
-- |Parse a Turtle document from the given 'ByteString' using the given @baseUrl@ and
-- @docUri@, which have the same semantics as in the loadTurtle* functions.
@@ -54,12 +53,12 @@ mkTurtleParser b d = parseTurtleRDF ((BaseUrl . B.pack) `fmap` b) (B.pack `fmap`
--
-- This function calls 'error' with an error message if unable to load the file.
loadNTriplesFile :: forall rdf. (RDF rdf) => String -> IO rdf
-loadNTriplesFile = _load (parseFile parseNTriplesRDF)
+loadNTriplesFile = _load (parseFile' parseNTriplesRDF)
-- |Load an NTriples file from a URL just like 'loadNTriplesFile' does from the local
-- filesystem. See that function for more info.
loadNTriplesURL :: forall rdf. (RDF rdf) => String -> IO rdf
-loadNTriplesURL = _load (parseURL parseNTriplesRDF)
+loadNTriplesURL = _load (parseURL' parseNTriplesRDF)
-- |Parse an NTriples document from the given 'ByteString', as 'loadNTriplesFile' does
-- from a file.
@@ -3,14 +3,13 @@
-- <http://www.w3.org/TR/rdf-testcases/#ntriples>.
module Text.RDF.RDF4H.NTriplesParser(
- NTriplesParser(NTriplesParser), ParseFailure,
+ NTriplesParser(NTriplesParser),
parseNTriplesRDF
) where
-- TODO: switch to OverloadedStrings and use ByteString literals (?).
import Data.RDF
-import Text.RDF.RDF4H.ParserUtils
import Data.Char(isLetter, isDigit, isLower)
import qualified Data.Map as Map
@@ -9,7 +9,6 @@ module Text.RDF.RDF4H.TurtleParser(
import Data.RDF
import Data.RDF.Namespace
-import Text.RDF.RDF4H.ParserUtils
import Text.Parsec
import Text.Parsec.ByteString.Lazy

0 comments on commit 0fca403

Please sign in to comment.