HToken.hs revision 76fa667489c5e0868ac68de9f0253ac10f73d0b5
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederModule : $Header$
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederCopyright : (c) Christian Maeder and Uni Bremen 2002-2004
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederLicence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederMaintainer : hets@tzi.de
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederStability : provisional
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederPortability : portable
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian Maeder parser for HasCASL IDs
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian Maeder extending "Common.Keywords" and "Common.Token"
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- * further HasCASL key signs
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian MaederassignS, minusS, plusS, pFun, contFun, pContFun, lamS, asP :: String
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaederassignS = ":="
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaederpFun = funS ++ quMark
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaedercontFun = minusS ++ funS
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaederpContFun = minusS ++ pFun
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- * further HasCASL keywords
c18e9c3c6d5039618f1f2c05526ece84c7794ea3Christian MaederinternalS, classS, programS, instanceS, caseS, ofS, letS, derivingS :: String
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaederclassS = "class"
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaederprogramS = "program"
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaederinstanceS = "instance"
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaedercaseS = "case"
fe883661c9d1a5a8b42ac4e8673ec133d9dad354Christian MaederderivingS = "deriving"
c18e9c3c6d5039618f1f2c05526ece84c7794ea3Christian MaederinternalS = "internal"
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- | the new keyword fun ('funS' is already defined differently)
ac510075311023bf24175f7a76b89ec2bbda0626Christian MaederfunctS :: String
c18e9c3c6d5039618f1f2c05526ece84c7794ea3Christian MaederfunctS = "fun"
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- * HasCASL keyword handling
8a1f427564a5ae2db32332512237ef645289c34dChristian Maederhascasl_reserved_ops, hascasl_type_ops :: [String]
613c474338a210f2aad9817376e5a3ce1fdde886Christian Maederhascasl_reserved_ops = [dotS++exMark, cDot++exMark, asP, assignS, lamS]
613c474338a210f2aad9817376e5a3ce1fdde886Christian Maeder ++ casl_reserved_ops
8a1f427564a5ae2db32332512237ef645289c34dChristian Maederhascasl_type_ops = [funS, pFun, contFun, pContFun, prodS, timesS, quMark]
8a1f427564a5ae2db32332512237ef645289c34dChristian Maederhascasl_reserved_words :: [String]
e05956d1da3c97e4d808926f97c6841c4a561991Christian Maederhascasl_reserved_words =
c18e9c3c6d5039618f1f2c05526ece84c7794ea3Christian Maeder [functS, functS ++ sS, classS, classS ++ "es", instanceS, instanceS ++ sS,
c18e9c3c6d5039618f1f2c05526ece84c7794ea3Christian Maeder programS, programS ++ sS, caseS, ofS, letS, derivingS, internalS]
613c474338a210f2aad9817376e5a3ce1fdde886Christian Maeder ++ casl_reserved_words
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maeder-- | HasCASL identifier words ('scanAnyWords')
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian MaederscanHCWords :: GenParser Char st String
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian MaederscanHCWords = reserved hascasl_reserved_words scanAnyWords
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maeder-- | HasCASL identifier signs ('scanAnySigns')
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian MaederscanHCSigns :: GenParser Char st String
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian MaederscanHCSigns = reserved hascasl_reserved_ops scanAnySigns
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- * HasCASL 'Id' parsers
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- | non-type variables ('lessS' additionally excluded)
b475a916d62584a2af5f51749240db7a5f0c8b82Christian Maedervar :: GenParser Char st Id
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maedervar = fmap (\l -> Id l [] []) (start (lessS : hascasl_reserved_ops,
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder hascasl_reserved_words))
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- | the HasCASL keys for 'mixId'
fd5d3885a092ac0727fa2436cdfc3b248318ebd8Christian MaederhcKeys :: ([String], [String])
fd5d3885a092ac0727fa2436cdfc3b248318ebd8Christian MaederhcKeys = (hascasl_reserved_ops, hascasl_reserved_words)
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- | operation 'Id' (reserved stuff excluded)
ac510075311023bf24175f7a76b89ec2bbda0626Christian MaederuninstOpId :: GenParser Char st Id
fd5d3885a092ac0727fa2436cdfc3b248318ebd8Christian MaederuninstOpId = mixId hcKeys hcKeys
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- | constructor 'Id' ('barS' additionally excluded)
ac510075311023bf24175f7a76b89ec2bbda0626Christian MaederhconsId :: GenParser Char st Id
37bd4066d4a1d6bf8126681f920165aa9a873d91Christian MaederhconsId = mixId (barS:hascasl_reserved_ops, hascasl_reserved_words)
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- | mixfix and compound type 'Id' (more signs excluded)
ac510075311023bf24175f7a76b89ec2bbda0626Christian MaedertypeId :: GenParser Char st Id
ac510075311023bf24175f7a76b89ec2bbda0626Christian MaedertypeId = mixId (lessS:equalS:barS:hascasl_type_ops++hascasl_reserved_ops,
37bd4066d4a1d6bf8126681f920165aa9a873d91Christian Maeder hascasl_reserved_words) hcKeys
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- | simple 'Id' without compound list (only a words)
fd5d3885a092ac0727fa2436cdfc3b248318ebd8Christian MaedertypeVar :: GenParser Char st Id
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian MaedertypeVar = do s <- pToken scanHCWords
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder return $ Id [s] [] []
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder-- | simple 'Id' possibly with compound list
7c57322afb6342e5cc8b1fdc96050b707407fc61Christian MaederclassId :: GenParser Char st Id
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maeder do s <- pToken scanHCWords
fd5d3885a092ac0727fa2436cdfc3b248318ebd8Christian Maeder (c, p) <- option ([], []) $ comps hcKeys
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder return $ Id [s] c p