Fixed the infinite loop
This commit is contained in:
parent
b87917dc2e
commit
c12458a2bf
3 changed files with 8 additions and 7 deletions
|
@ -6,4 +6,4 @@ main :: IO ()
|
|||
main = do
|
||||
text <- getContents
|
||||
|
||||
print $ Parsec.parse (File.parse <* Parsec.eof) "<stdin>" text
|
||||
print $ Parsec.parse (File.parse "<stdin>" <* Parsec.eof) "<stdin>" text
|
||||
|
|
|
@ -19,7 +19,7 @@ import qualified Ubc.Parse.Syntax.Struct as Struct
|
|||
import qualified Ubc.Parse.Syntax.Function as Function
|
||||
import qualified Ubc.Parse.Syntax.Statement as Statement
|
||||
import qualified Ubc.Parse.Syntax.Enumeration as Enumeration
|
||||
import GHC.Generics (Generic)
|
||||
import GHC.Generics (Generic, Generically(..))
|
||||
import Data.Functor ((<&>))
|
||||
|
||||
data File = File
|
||||
|
@ -35,10 +35,11 @@ data FileBody = FileBody
|
|||
, enumerations :: [Enumeration]
|
||||
}
|
||||
deriving stock (Show, Generic)
|
||||
deriving (Semigroup, Monoid) via FileBody
|
||||
deriving (Semigroup, Monoid) via Generically FileBody
|
||||
-- dont use `deriving ... via FileBody` because that leads to a loop, somehow
|
||||
|
||||
parse :: Monad m => ParsecT String u m File
|
||||
parse = File "" <$!> mconcat <$!> many fileMember
|
||||
parse :: Monad m => String -> ParsecT String u m File
|
||||
parse source = File source <$!> mconcat <$!> many fileMember
|
||||
|
||||
fileMember :: Monad m => ParsecT String u m FileBody
|
||||
fileMember = choice
|
||||
|
|
|
@ -7,7 +7,7 @@ module Ubc.Parse.Syntax.Struct
|
|||
where
|
||||
|
||||
-- yay, explicit dependency on ghc
|
||||
import GHC.Generics (Generic)
|
||||
import GHC.Generics (Generic, Generically(..))
|
||||
|
||||
import Control.Monad ((<$!>))
|
||||
|
||||
|
@ -39,7 +39,7 @@ data StructBody = StructBody
|
|||
, functions :: [Function]
|
||||
}
|
||||
deriving stock (Generic, Show)
|
||||
deriving (Semigroup, Monoid) via StructBody
|
||||
deriving (Semigroup, Monoid) via Generically StructBody
|
||||
|
||||
parse :: Monad m => ParsecT String u m Struct
|
||||
parse = do
|
||||
|
|
Loading…
Reference in a new issue