Parse_CspCASL.hs revision 63f8854d42e766ff77125c6e532c5fce3b5ebdef
e83ed59502a681713982f25c559aae77a4145734Christian Maeder{- |
eb483f2216949400bfef8f6deb5320f071445626Christian MaederModule : $Id$
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiDescription : Parser for CspCASL specifications
eb483f2216949400bfef8f6deb5320f071445626Christian MaederCopyright : (c) Uni Bremen 2007
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : a.m.gimblett@swan.ac.uk
eb483f2216949400bfef8f6deb5320f071445626Christian MaederStability : experimental
eb483f2216949400bfef8f6deb5320f071445626Christian MaederPortability : portable
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiParser for CSP-CASL specifications.
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-}
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder
eb483f2216949400bfef8f6deb5320f071445626Christian Maedermodule CspCASL.Parse_CspCASL (
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder cspBasicSpec
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder) where
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederimport Text.ParserCombinators.Parsec (many1, try, (<|>), option, sepBy)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederimport Common.AnnoState (AParser, asKey, equalT, anSemi)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederimport Common.Id (genName)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederimport CASL.Formula
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederimport CspCASL.AS_CspCASL
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederimport CspCASL.CspCASL_Keywords
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederimport CspCASL.Parse_CspCASL_Process
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
e83ed59502a681713982f25c559aae77a4145734Christian MaedercspBasicSpec :: AParser st CspBasicSpec
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaedercspBasicSpec = do
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder option [] $ do
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder asKey "channel"
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder varDecl csp_casl_keywords `sepBy` anSemi
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder return []
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder pp <- processPart
e83ed59502a681713982f25c559aae77a4145734Christian Maeder return (CspBasicSpec [] pp)
e83ed59502a681713982f25c559aae77a4145734Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederprocessPart :: AParser st [PROC_EQ]
e83ed59502a681713982f25c559aae77a4145734Christian MaederprocessPart = do
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder asKey processS
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder procEqs <|> fmap toDummyEq csp_casl_process
e83ed59502a681713982f25c559aae77a4145734Christian Maeder where
e83ed59502a681713982f25c559aae77a4145734Christian Maeder toDummyEq p = [(ProcEq dummyName p)]
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder dummyName = ParmProcname singletonProcessName []
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder -- Default name allocated to unnamed singleton processes.
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder singletonProcessName = genName "P"
e83ed59502a681713982f25c559aae77a4145734Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederprocEqs :: AParser st [PROC_EQ]
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederprocEqs = many1 procEq
e83ed59502a681713982f25c559aae77a4145734Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederprocEq :: AParser st PROC_EQ
e83ed59502a681713982f25c559aae77a4145734Christian MaederprocEq = do
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder pn <- try (do
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder pn <- parmProcname
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder equalT
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder return pn)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder p <- csp_casl_process
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder return (ProcEq pn p)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederparmProcname :: AParser st PARM_PROCNAME
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederparmProcname = do
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder pn <- process_name
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder pa <- procArgs
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder return (ParmProcname pn pa)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder