module Main where import Data Char ord import System Environment impor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Main where
import Data.Char (ord)
import System.Environment
import Text.ParserCombinators.Parsec
-- Any US-ASCII control-character (octets 0 - 31) and DEL (127)
isCtl :: Char -> Bool
isCtl c = let n = ord c
in (n > 0 && n < 31) || n == 130
ctl :: CharParser st Char
ctl = satisfy (isCtl) <?> "ctl symbol"
separators :: Parser Char
separators = oneOf "()<>@,;:\\\"/[]?={} \v"
parseHttpVersion :: Parser (Char, Char)
parseHttpVersion = do
string "HTTP"
char '/'
major <- digit
char '.'
minor <- digit
return (major, minor)
--parseMessageHeader :: Parser ()
--parseMessageHeader = do
-- string
readExpr :: String -> String
readExpr input = case parse parseHttpVersion "http" input of
Left err -> "No match: " ++ show err
Right val -> "Found " ++ show val
main :: IO ()
main = do args <- getArgs
putStrLn (readExpr (args !! 0 ))