diff --git a/Registry/Registry.hs b/Registry/Registry.hs index 27787a0..ec1e6dd 100644 --- a/Registry/Registry.hs +++ b/Registry/Registry.hs @@ -31,6 +31,8 @@ getRegistry input = else registryOf reg +dateOf (Date d) = d + isValidLanguage l dict = if length (filter (onlyThisValue "language" l) dict) == 1 then (True, "") diff --git a/Registry/check-registry.hs b/Registry/check-registry.hs index 341750e..42f5e17 100644 --- a/Registry/check-registry.hs +++ b/Registry/check-registry.hs @@ -71,18 +71,19 @@ main = do input <- System.IO.readFile registryfilename let syntaxTree = parse input if (checkOK syntaxTree) then do + let theDate = dateOf (head (registryOf syntaxTree)) let result = semanticCheck (registryOf syntaxTree) if (checkOK result) then do if verbose opts then - putStrLn (registryfilename ++ " is OK") -- TODO: display the date + putStrLn (registryfilename ++ " of " ++ theDate ++ " is OK") else nothing Exit.exitWith Exit.ExitSuccess else do - putStrLn ("Semantic error in " ++ registryfilename ++ ": " ++ + putStrLn ("Semantic error in " ++ registryfilename ++ " of " ++ theDate ++ ": " ++ (messageOf result)) Exit.exitWith (Exit.ExitFailure 3) else do putStrLn ("Syntax error in " ++ registryfilename ++ ": " ++ (messageOf syntaxTree)) - Exit.exitWith (Exit.ExitFailure 2) \ No newline at end of file + Exit.exitWith (Exit.ExitFailure 2) diff --git a/check-valid.hs b/check-valid.hs index a38963e..976169d 100644 --- a/check-valid.hs +++ b/check-valid.hs @@ -4,14 +4,15 @@ import Registry.Registry infile = "./language-subtag-registry" -analyze reg input - = case (getTag input) of +analyze reg input = do + let theDate = dateOf (head reg) + case (getTag input) of Left err -> err Right tag -> let result = isValid reg tag in if fst result then - (input ++ " is valid\n") -- TODO: indicate the date of the registry + (input ++ " is valid against registry " ++ theDate ++ "\n") else - (input ++ " is NOT valid: " ++ snd result ++ "\n") + (input ++ " is NOT valid against registry " ++ theDate ++ ": " ++ snd result ++ "\n") main = do myargs <- getArgs