Parse_CspCASL.hs revision f909337bf7012aca169c0b56b89efbd4a310f8da
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederDescription : Parser for CspCASL specifications
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederCopyright : (c) Uni Bremen 2007
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederMaintainer : a.m.gimblett@swan.ac.uk
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederStability : experimental
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederPortability : portable
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederParser for CSP-CASL specifications.
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport Text.ParserCombinators.Parsec (choice, many1, try, (<|>),
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder option, sepBy)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport Common.AnnoState (AParser, asKey, colonT, equalT, anSemi)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport Common.Id (genName)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport Common.Lexer (commaSep1, cParenT, oParenT)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaedercspBasicSpec :: AParser st CspBasicSpec
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaedercspBasicSpec = do
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder option [] $ do
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder choice [asKey channelS, asKey channelsS] -- "channel" or "channels"
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder cds <- chanDecl `sepBy` anSemi
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder --anSemi -- optional final semicolon. How?
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder items <- processItems
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder let (decls, eqs) = splitProcItems items
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder return (basicToCore (CspBasicSpec [] decls eqs))
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederchanDecl :: AParser st CHANNEL
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederchanDecl = do vs <- commaSep1 var
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder es <- event_set
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder return (Channel vs es)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maedertype PROC_ITEM = Either PROC_DECL PROC_EQ
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederprocessItems :: AParser st [PROC_ITEM]
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederprocessItems = do asKey processS
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder procItems <|> fmap singleProcess csp_casl_process
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder-- Turn an unnamed singleton process into a declaration/equation.
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaedersingleProcess :: PROCESS -> [PROC_ITEM]
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaedersingleProcess p =