Added Generics to functions and structs
This commit is contained in:
parent
ac0e697622
commit
21bec764db
5 changed files with 37 additions and 8 deletions
|
@ -12,12 +12,15 @@ import Text.Parsec (lookAhead, try, ParsecT)
|
|||
import Ubc.Parse.Syntax.VariableType (VariableType)
|
||||
import {-# SOURCE #-} Ubc.Parse.Syntax.Expression (Expression, expressionParser)
|
||||
|
||||
import Ubc.Parse.Syntax.Generic (Generic)
|
||||
import qualified Ubc.Parse.Syntax.Language as UbcLanguage
|
||||
import qualified Ubc.Parse.Syntax.VariableType as VariableType
|
||||
import qualified Ubc.Parse.Syntax.Generic as Generic
|
||||
|
||||
data Function = Function
|
||||
{ identifier :: String
|
||||
, returnType :: VariableType
|
||||
{ returnType :: VariableType
|
||||
, identifier :: String
|
||||
, generics :: [Generic]
|
||||
, body :: Expression
|
||||
, arguments :: [(VariableType, String)]
|
||||
}
|
||||
|
@ -25,11 +28,13 @@ data Function = Function
|
|||
|
||||
parsePrefixed :: Monad m => VariableType -> String -> ParsecT String u m Function
|
||||
parsePrefixed ftype fname = do
|
||||
genericList <- UbcLanguage.angles $ UbcLanguage.commaSeparated1 Generic.parse
|
||||
|
||||
argumentList <- UbcLanguage.parens (UbcLanguage.commaSeparated argumentDefinition)
|
||||
|
||||
expressionBody <- expressionParser
|
||||
|
||||
return $ Function fname ftype expressionBody argumentList
|
||||
return $ Function ftype fname genericList expressionBody argumentList
|
||||
|
||||
parse :: Monad m => ParsecT String u m Function
|
||||
parse = do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue