-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathParse_CspCASL.hs
52 lines (43 loc) · 1.26 KB
/
Parse_CspCASL.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{- |
Module : ./CspCASL/Parse_CspCASL.hs
Description : Parser for CspCASL specifications
Copyright : (c) Uni Bremen 2007
License : GPLv2 or higher, see LICENSE.txt
Maintainer : a.m.gimblett@swan.ac.uk
Stability : experimental
Portability : portable
Parser for CSP-CASL specifications.
-}
module CspCASL.Parse_CspCASL (cspBasicExt) where
import Text.ParserCombinators.Parsec
import Common.AnnoState
import Common.Lexer
import CspCASL.AS_CspCASL
import CspCASL.CspCASL_Keywords
import CspCASL.Parse_CspCASL_Process
instance AParsable CspBasicExt where
aparser = cspBasicExt
cspBasicExt :: AParser st CspBasicExt
cspBasicExt =
itemList cspKeywords channelS (const chanDecl) Channels
<|> do
p <- asKey processS
auxItemList cspStartKeys [p] procItem ProcItems
chanDecl :: AParser st CHANNEL_DECL
chanDecl = do
vs <- commaSep1 channel_name
colonT
es <- cspSortId
return (ChannelDecl vs es)
procItem :: AParser st PROC_ITEM
procItem = do
ep <- procDeclOrDefn
case ep of
Left (fpn, vs) -> do
p <- csp_casl_process
return $ Proc_Eq (ParmProcname fpn vs) p
Right (pn, eas, al) -> case eas of
Left ss -> return $ Proc_Decl pn ss al
Right vds -> do
p <- csp_casl_process
return $ Proc_Defn pn vds al p