-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.hs
More file actions
28 lines (25 loc) · 967 Bytes
/
Copy pathMain.hs
File metadata and controls
28 lines (25 loc) · 967 Bytes
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
import Types
import GrammarParser
import System.Environment
import Control.Monad
import Chomsky
import Cyk
main :: IO ()
main = do
[inputPath, inputWordsPath] <- getArgs
fileContent <- readFile inputPath
inputWords <- readFile inputWordsPath
let words = [ stringToWord w | w <- lines inputWords]
let parsedGrammar = chomsky $ stringToGrammar fileContent
let result = [ (w ,isInLanguage w parsedGrammar) | w <- words]
mapM (print) (lines $ grammarToString parsedGrammar)
print result
----Only one arg: filePath for reading
--main :: IO ()
--main = do
-- run getArgs
--
--run :: [String] -> IO()
--run [inputPath] = print $stringToGrammar $readFile inputPath
--run [inputPath, outputPath] = writeFile outputPath $grammarToString $stringToGrammar $readFile inputPath
--run _ = error "A program futtatasahoz legalabb egy argumentum szukseges. Annak pedig a beolvasando fajl eleresi cimenek kell lennie.";