mirror of
https://github.com/macocianradu/RosettaHaskellCompiler.git
synced 2026-03-18 13:00:08 +00:00
fixed cardinality checks on if statements
This commit is contained in:
11
app/Main.hs
11
app/Main.hs
@@ -17,6 +17,8 @@ import Model.Type
|
|||||||
import System.Environment.Blank (getArgs)
|
import System.Environment.Blank (getArgs)
|
||||||
import Model.Enum
|
import Model.Enum
|
||||||
import Data.Either
|
import Data.Either
|
||||||
|
import Model.Header
|
||||||
|
import Parser.Header
|
||||||
|
|
||||||
-- :set args resources/testAll.rosetta resources/Generated/testAll.hs
|
-- :set args resources/testAll.rosetta resources/Generated/testAll.hs
|
||||||
-- :l resources/Generated/testAll.hs
|
-- :l resources/Generated/testAll.hs
|
||||||
@@ -25,11 +27,9 @@ main :: IO ()
|
|||||||
main = do
|
main = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
rosettaString <- readFile $ head args
|
rosettaString <- readFile $ head args
|
||||||
-- |Parse the string read from the input file
|
|
||||||
case parse rosettaParser "" (Text.pack rosettaString) of
|
case parse rosettaParser "" (Text.pack rosettaString) of
|
||||||
Left errorBundle -> print (errorBundlePretty errorBundle)
|
Left errorBundle -> print (errorBundlePretty errorBundle)
|
||||||
Right objs -> do
|
Right objs -> do
|
||||||
-- |Write the haskell string into the second argument
|
|
||||||
writeFile (args !! 1) (printObjects (definedTypes, definedFunctions) objs)
|
writeFile (args !! 1) (printObjects (definedTypes, definedFunctions) objs)
|
||||||
where
|
where
|
||||||
-- |Adds all the function definitions from the file into the symbol table
|
-- |Adds all the function definitions from the file into the symbol table
|
||||||
@@ -77,8 +77,11 @@ addNewTypes defined (EnumObject (MakeEnum name _ _): os) = addDefinedTypes (addN
|
|||||||
addNewTypes defined (_ :os) = addNewTypes defined os
|
addNewTypes defined (_ :os) = addNewTypes defined os
|
||||||
|
|
||||||
-- |Parses any supported Rosetta types into a list of RosettaObject
|
-- |Parses any supported Rosetta types into a list of RosettaObject
|
||||||
rosettaParser :: Parser [RosettaObject]
|
rosettaParser :: Parser (Header, [RosettaObject])
|
||||||
rosettaParser = many (try parseEnum <|> try parseType <|> try parseFunction) <* eof
|
rosettaParser = do
|
||||||
|
header <- headerParser
|
||||||
|
objects <- many (try parseEnum <|> try parseType <|> try parseFunction) <* eof
|
||||||
|
return (header, objects)
|
||||||
|
|
||||||
-- |Reads an enum into a RosettaObject
|
-- |Reads an enum into a RosettaObject
|
||||||
parseEnum :: Parser RosettaObject
|
parseEnum :: Parser RosettaObject
|
||||||
|
|||||||
Reference in New Issue
Block a user