Added Generics to functions and structs
This commit is contained in:
parent
ac0e697622
commit
21bec764db
5 changed files with 37 additions and 8 deletions
|
@ -25,11 +25,13 @@ import Ubc.Parse.Syntax.Function (Function)
|
|||
import qualified Ubc.Parse.Syntax.Language as UbcLanguage
|
||||
import qualified Ubc.Parse.Syntax.VariableType as VariableType
|
||||
import qualified Ubc.Parse.Syntax.Function as Function
|
||||
import qualified Ubc.Parse.Syntax.Generic as Syntax.Generic
|
||||
|
||||
type VariableName = String
|
||||
|
||||
data Struct = Struct
|
||||
{ name :: String
|
||||
, generics :: [Syntax.Generic.Generic]
|
||||
, body :: StructBody
|
||||
}
|
||||
deriving (Show)
|
||||
|
@ -45,9 +47,10 @@ parse :: Monad m => ParsecT String u m Struct
|
|||
parse = do
|
||||
_ <- UbcLanguage.reserved "struct"
|
||||
structIdentifier <- UbcLanguage.identifier
|
||||
structGenerics <- UbcLanguage.angles $ UbcLanguage.commaSeparated1 Syntax.Generic.parse
|
||||
structBody <- mconcat <$!> UbcLanguage.braces (many structMember)
|
||||
|
||||
pure $ Struct structIdentifier structBody
|
||||
pure $ Struct structIdentifier structGenerics structBody
|
||||
|
||||
structMember :: Monad m => ParsecT String u m StructBody
|
||||
structMember = choice [ structVariableOrFunction ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue