Language.C.Data.InputStream

language-c-0.6.1: Analysis and generation of C code

Copyright | (c) 2008,2011 Benedikt Huber
License | BSD-style
Maintainer | benedikt.huber@gmail.com
Stability | experimental
Portability | ghc
Safe Haskell | None
Language | Haskell98

Language.C.Data.InputStream

Description

Compile time input abstraction for the parser, relying on ByteString. The String interface only supports Latin-1 since alex-3, as alex now requires byte based access to the input stream.

Synopsis

- type InputStream = ByteString
- readInputStream :: FilePath -> IO InputStream
- inputStreamToString :: InputStream -> String
- inputStreamFromString :: String -> InputStream
- takeByte :: InputStream -> (Word8, InputStream)
- takeChar :: InputStream -> (Char, InputStream)
- inputStreamEmpty :: InputStream -> Bool
- takeChars :: Int -> InputStream -> [Char]
- countLines :: InputStream -> Int

# Documentation

type InputStream = ByteString #

readInputStream :: FilePath -> IO InputStream #

read a file into an `InputStream`

inputStreamToString :: InputStream -> String #

convert `InputStream` to `String`

inputStreamFromString :: String -> InputStream #

convert a `String` to an `InputStream`

takeByte :: InputStream -> (Word8, InputStream) #

`(b,is') = takeByte is` reads and removes the first byte `b` from the `InputStream` `is`

takeChar :: InputStream -> (Char, InputStream) #

`(c,is') = takeChar is` reads and removes the first character `c` from the `InputStream` `is`

inputStreamEmpty :: InputStream -> Bool #

return `True` if the given input stream is empty

takeChars :: Int -> InputStream -> [Char] #

`str = takeChars n is` returns the first `n` characters of the given input stream, without removing them

countLines :: InputStream -> Int #

`countLines` returns the number of text lines in the given `InputStream`