Skip to content

Instantly share code, notes, and snippets.

@yanok
Created May 5, 2018 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanok/816f6f904baeefe562b09813eda9c61e to your computer and use it in GitHub Desktop.
Save yanok/816f6f904baeefe562b09813eda9c61e to your computer and use it in GitHub Desktop.
module Main where
import System.Environment
import System.Exit
import Text.Parsec
main :: IO ()
main = do
args <- getArgs
case args of
[fileName] -> do
contents <- readFile fileName
case parse parseGrammar fileName contents of
Left err -> do
print err
exitFailure
Right gr -> do
let gr' = augmentGrammar gr
print gr' -- this requires Show instance for grammar
let states = grammarToLRStates gr'
mapM_ print states -- this assumes states in a list and there is a Show instance for state
_ -> do
putStrLn "Usage: ..."
exitFailure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment