Added various keywords, AST elements and parser bits related to channel bundles, claim blocks and shared channels
This commit is contained in:
parent
3ae4824184
commit
5f9d0c6429
|
@ -124,6 +124,8 @@ data Type =
|
||||||
| List Type
|
| List Type
|
||||||
-- | A user-defined data type.
|
-- | A user-defined data type.
|
||||||
| UserDataType Name
|
| UserDataType Name
|
||||||
|
-- | An end of a channel bundle
|
||||||
|
| ChanDataType Direction ShareMode Name
|
||||||
-- | A record type.
|
-- | A record type.
|
||||||
| Record Name
|
| Record Name
|
||||||
-- | A user-defined protocol.
|
-- | A user-defined protocol.
|
||||||
|
@ -491,6 +493,8 @@ data SpecType =
|
||||||
-- | Declare a new record type.
|
-- | Declare a new record type.
|
||||||
-- The list is the fields of the record.
|
-- The list is the fields of the record.
|
||||||
| RecordType Meta RecordAttr [(Name, Type)]
|
| RecordType Meta RecordAttr [(Name, Type)]
|
||||||
|
-- | Declares a mobile channel bundle.
|
||||||
|
| ChanBundleType Meta RecMode [(Name, Type)]
|
||||||
-- | Declare a simple protocol.
|
-- | Declare a simple protocol.
|
||||||
-- The list contains the types of the items.
|
-- The list contains the types of the items.
|
||||||
| Protocol Meta [Type]
|
| Protocol Meta [Type]
|
||||||
|
@ -581,6 +585,7 @@ data Process =
|
||||||
-- This may go away in the future, since which @PROC@s are intrinsics depends
|
-- This may go away in the future, since which @PROC@s are intrinsics depends
|
||||||
-- on the backend.
|
-- on the backend.
|
||||||
| IntrinsicProcCall Meta String [Actual]
|
| IntrinsicProcCall Meta String [Actual]
|
||||||
|
| Claim Meta Variable Process
|
||||||
deriving (Show, Eq, Typeable, Data)
|
deriving (Show, Eq, Typeable, Data)
|
||||||
|
|
||||||
-- | The top level of the AST: a sequence of definitions.
|
-- | The top level of the AST: a sequence of definitions.
|
||||||
|
|
|
@ -61,7 +61,7 @@ data PreprocDef =
|
||||||
-- particular context; in later passes you can look at how the name is actually
|
-- particular context; in later passes you can look at how the name is actually
|
||||||
-- defined, which is more useful.
|
-- defined, which is more useful.
|
||||||
data NameType =
|
data NameType =
|
||||||
ChannelName | DataTypeName | FunctionName | FieldName | PortName
|
ChannelName | ChanBundleName | DataTypeName | FunctionName | FieldName | PortName
|
||||||
| ProcName | ProtocolName | RecordName | TagName | TimerName | VariableName
|
| ProcName | ProtocolName | RecordName | TagName | TimerName | VariableName
|
||||||
deriving (Show, Eq, Typeable, Data)
|
deriving (Show, Eq, Typeable, Data)
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ $vertSpace = [\r\n]
|
||||||
| "|"
|
| "|"
|
||||||
| "AFTER" | "ALT" | "AND" | "ANY" | "AT"
|
| "AFTER" | "ALT" | "AND" | "ANY" | "AT"
|
||||||
| "BITAND" | "BITNOT" | "BITOR" | "BOOL" | "BYTE" | "BYTESIN"
|
| "BITAND" | "BITNOT" | "BITOR" | "BOOL" | "BYTE" | "BYTESIN"
|
||||||
| "CASE" | "CHAN" | "CLONE"
|
| "CASE" | "CHAN" | "CLAIM" | "CLONE"
|
||||||
| "DATA" | "DEFINED"
|
| "DATA" | "DEFINED"
|
||||||
| "ELSE"
|
| "ELSE"
|
||||||
| "FALSE" | "FOR" | "FROM" | "FUNCTION"
|
| "FALSE" | "FOR" | "FROM" | "FUNCTION"
|
||||||
|
@ -66,7 +66,7 @@ $vertSpace = [\r\n]
|
||||||
| "PRI" | "PROC" | "PROCESSOR" | "PROTOCOL"
|
| "PRI" | "PROC" | "PROCESSOR" | "PROTOCOL"
|
||||||
| "REAL32" | "REAL64" | "REC" | "RECORD" | "RECURSIVE" | "REM" | "RESHAPES"
|
| "REAL32" | "REAL64" | "REC" | "RECORD" | "RECURSIVE" | "REM" | "RESHAPES"
|
||||||
| "RESULT" | "RETYPES" | "ROUND"
|
| "RESULT" | "RETYPES" | "ROUND"
|
||||||
| "SEQ" | "SIZE" | "SKIP" | "STEP" | "STOP"
|
| "SEQ" | "SHARED" | "SIZE" | "SKIP" | "STEP" | "STOP"
|
||||||
| "TIMER" | "TIMES" | "TRUE" | "TRUNC" | "TYPE"
|
| "TIMER" | "TIMES" | "TRUE" | "TRUNC" | "TYPE"
|
||||||
| "VAL" | "VALOF"
|
| "VAL" | "VALOF"
|
||||||
| "WHILE" | "WORKSPACE"
|
| "WHILE" | "WORKSPACE"
|
||||||
|
|
|
@ -110,14 +110,16 @@ sRightR = reserved ")"
|
||||||
sSemi = reserved ";"
|
sSemi = reserved ";"
|
||||||
--}}}
|
--}}}
|
||||||
--{{{ keywords
|
--{{{ keywords
|
||||||
|
|
||||||
sAFTER, sALT, sAND, sANY, sAT, sBITAND, sBITNOT, sBITOR, sBOOL, sBYTE,
|
sAFTER, sALT, sAND, sANY, sAT, sBITAND, sBITNOT, sBITOR, sBOOL, sBYTE,
|
||||||
sBYTESIN, sCASE, sCHAN, sCLONE, sDATA, sDEFINED, sELSE, sFALSE, sFOR, sFROM,
|
sBYTESIN, sCASE, sCHAN, sCLAIM, sCLONE, sDATA, sDEFINED, sELSE, sFALSE,
|
||||||
sFUNCTION, sIF, sINLINE, sIN, sINITIAL, sINT, sINT16, sINT32, sINT64, sIS,
|
sFOR, sFROM, sFUNCTION, sIF, sINLINE, sIN, sINITIAL, sINT, sINT16, sINT32,
|
||||||
sMINUS, sMOBILE, sMOSTNEG, sMOSTPOS, sNOT, sOF, sOFFSETOF, sOR, sPACKED,
|
sINT64, sIS, sMINUS, sMOBILE, sMOSTNEG, sMOSTPOS, sNOT, sOF, sOFFSETOF, sOR,
|
||||||
sPAR, sPLACE, sPLACED, sPLUS, sPORT, sPRI, sPROC, sPROCESSOR, sPROTOCOL,
|
sPACKED, sPAR, sPLACE, sPLACED, sPLUS, sPORT, sPRI, sPROC, sPROCESSOR,
|
||||||
sREAL32, sREAL64, sRECORD, sREC_RECURSIVE, sREM, sRESHAPES, sRESULT,
|
sPROTOCOL, sREAL32, sREAL64, sRECORD, sREC_RECURSIVE, sREM, sRESHAPES,
|
||||||
sRETYPES, sROUND, sSEQ, sSIZE, sSKIP, sSTEP, sSTOP, sTIMER, sTIMES, sTRUE,
|
sRESULT, sRETYPES, sROUND, sSEQ, sSHARED, sSIZE, sSKIP, sSTEP, sSTOP,
|
||||||
sTRUNC, sTYPE, sVAL, sVALOF, sWHILE, sWORKSPACE, sVECSPACE
|
sTIMER, sTIMES, sTRUE, sTRUNC, sTYPE, sVAL, sVALOF, sWHILE, sWORKSPACE,
|
||||||
|
sVECSPACE
|
||||||
:: OccParser ()
|
:: OccParser ()
|
||||||
|
|
||||||
sAFTER = reserved "AFTER"
|
sAFTER = reserved "AFTER"
|
||||||
|
@ -133,6 +135,7 @@ sBYTE = reserved "BYTE"
|
||||||
sBYTESIN = reserved "BYTESIN"
|
sBYTESIN = reserved "BYTESIN"
|
||||||
sCASE = reserved "CASE"
|
sCASE = reserved "CASE"
|
||||||
sCHAN = reserved "CHAN"
|
sCHAN = reserved "CHAN"
|
||||||
|
sCLAIM = reserved "CLAIM"
|
||||||
sCLONE = reserved "CLONE"
|
sCLONE = reserved "CLONE"
|
||||||
sDATA = reserved "DATA"
|
sDATA = reserved "DATA"
|
||||||
sDEFINED = reserved "DEFINED"
|
sDEFINED = reserved "DEFINED"
|
||||||
|
@ -178,6 +181,7 @@ sRESULT = reserved "RESULT"
|
||||||
sRETYPES = reserved "RETYPES"
|
sRETYPES = reserved "RETYPES"
|
||||||
sROUND = reserved "ROUND"
|
sROUND = reserved "ROUND"
|
||||||
sSEQ = reserved "SEQ"
|
sSEQ = reserved "SEQ"
|
||||||
|
sSHARED = reserved "SHARED"
|
||||||
sSIZE = reserved "SIZE"
|
sSIZE = reserved "SIZE"
|
||||||
sSKIP = reserved "SKIP"
|
sSKIP = reserved "SKIP"
|
||||||
sSTEP = reserved "STEP"
|
sSTEP = reserved "STEP"
|
||||||
|
@ -464,11 +468,12 @@ name nt
|
||||||
newName :: NameType -> OccParser A.Name
|
newName :: NameType -> OccParser A.Name
|
||||||
newName nt = anyName nt
|
newName nt = anyName nt
|
||||||
|
|
||||||
channelName, dataTypeName, functionName, portName, procName, protocolName,
|
channelName, chanBundleName, dataTypeName, functionName, portName, procName, protocolName,
|
||||||
recordName, timerName, variableName
|
recordName, timerName, variableName
|
||||||
:: OccParser A.Name
|
:: OccParser A.Name
|
||||||
|
|
||||||
channelName = name ChannelName
|
channelName = name ChannelName
|
||||||
|
chanBundleName = name ChanBundleName
|
||||||
dataTypeName = name DataTypeName
|
dataTypeName = name DataTypeName
|
||||||
functionName = name FunctionName
|
functionName = name FunctionName
|
||||||
portName = name PortName
|
portName = name PortName
|
||||||
|
@ -478,12 +483,13 @@ recordName = name RecordName
|
||||||
timerName = name TimerName
|
timerName = name TimerName
|
||||||
variableName = name VariableName
|
variableName = name VariableName
|
||||||
|
|
||||||
newChannelName, newDataTypeName, newFunctionName, newPortName,
|
newChannelName, newChanBundleName, newDataTypeName, newFunctionName, newPortName,
|
||||||
newProcName, newProtocolName, newRecordName, newTimerName,
|
newProcName, newProtocolName, newRecordName, newTimerName,
|
||||||
newVariableName
|
newVariableName
|
||||||
:: OccParser A.Name
|
:: OccParser A.Name
|
||||||
|
|
||||||
newChannelName = newName ChannelName
|
newChannelName = newName ChannelName
|
||||||
|
newChanBundleName = newName ChanBundleName
|
||||||
newDataTypeName = newName DataTypeName
|
newDataTypeName = newName DataTypeName
|
||||||
newFunctionName = newName FunctionName
|
newFunctionName = newName FunctionName
|
||||||
newPortName = newName PortName
|
newPortName = newName PortName
|
||||||
|
@ -539,6 +545,8 @@ dataType
|
||||||
-- Mobile arrays can lack dimensions:
|
-- Mobile arrays can lack dimensions:
|
||||||
<|> do { tryXV sMOBILE (specArrayType dataType) >>* A.Mobile }
|
<|> do { tryXV sMOBILE (specArrayType dataType) >>* A.Mobile }
|
||||||
<|> do { tryXV sMOBILE dataType >>* A.Mobile }
|
<|> do { tryXV sMOBILE dataType >>* A.Mobile }
|
||||||
|
<|> do { (n, dir) <- tryVV chanBundleName direction; return $ A.ChanDataType dir A.Unshared n }
|
||||||
|
<|> do { (n, dir) <- tryXVV sSHARED chanBundleName direction; return $ A.ChanDataType dir A.Shared n }
|
||||||
<|> do { n <- try dataTypeName; return $ A.UserDataType n }
|
<|> do { n <- try dataTypeName; return $ A.UserDataType n }
|
||||||
<|> do { n <- try recordName; return $ A.Record n }
|
<|> do { n <- try recordName; return $ A.Record n }
|
||||||
<?> "data type"
|
<?> "data type"
|
||||||
|
@ -872,6 +880,7 @@ channel
|
||||||
channel' :: OccParser A.Variable
|
channel' :: OccParser A.Variable
|
||||||
channel'
|
channel'
|
||||||
= do { m <- md; n <- try channelName; return $ A.Variable m n }
|
= do { m <- md; n <- try channelName; return $ A.Variable m n }
|
||||||
|
<|> do { m <- md; n <- try variableName; return $ A.Variable m n }
|
||||||
<|> maybeSliced directedChannel A.SubscriptedVariable
|
<|> maybeSliced directedChannel A.SubscriptedVariable
|
||||||
<?> "channel'"
|
<?> "channel'"
|
||||||
|
|
||||||
|
@ -1094,8 +1103,26 @@ definition
|
||||||
= do m <- md
|
= do m <- md
|
||||||
sDATA
|
sDATA
|
||||||
sTYPE
|
sTYPE
|
||||||
do { n <- tryVX newDataTypeName sIS; t <- dataType; sColon; eol; return (A.Specification m n (A.DataType m t), DataTypeName) }
|
do { n <- tryVX newDataTypeName sIS; t <- dataType; sColon; eol;
|
||||||
<|> do { n <- newRecordName; eol; indent; rec <- structuredType; outdent; sColon; eol; return (A.Specification m n rec, RecordName) }
|
return (A.Specification m n (A.DataType m t), DataTypeName) }
|
||||||
|
<|> do { n <- newRecordName; eol; indent; rec <- structuredType; outdent; sColon; eol;
|
||||||
|
return (A.Specification m n rec, RecordName) }
|
||||||
|
<|> do m <- md
|
||||||
|
rec <- recMode sCHAN >>* fst
|
||||||
|
sTYPE
|
||||||
|
n <- newChanBundleName
|
||||||
|
eol
|
||||||
|
indent
|
||||||
|
sMOBILE
|
||||||
|
sRECORD
|
||||||
|
eol
|
||||||
|
indent
|
||||||
|
fs <- many1 chanInBundle
|
||||||
|
outdent
|
||||||
|
outdent
|
||||||
|
sColon
|
||||||
|
eol
|
||||||
|
return (A.Specification m n $ A.ChanBundleType m rec fs, ChanBundleName)
|
||||||
<|> do m <- md
|
<|> do m <- md
|
||||||
sPROTOCOL
|
sPROTOCOL
|
||||||
n <- newProtocolName
|
n <- newProtocolName
|
||||||
|
@ -1138,6 +1165,15 @@ definition
|
||||||
return (A.Specification m n' $ A.Function m (sm, rm) rs fs' (Left vp), FunctionName) }
|
return (A.Specification m n' $ A.Function m (sm, rm) rs fs' (Left vp), FunctionName) }
|
||||||
<|> retypesAbbrev
|
<|> retypesAbbrev
|
||||||
<?> "definition"
|
<?> "definition"
|
||||||
|
where
|
||||||
|
chanInBundle :: OccParser (A.Name, A.Type)
|
||||||
|
chanInBundle = do sCHAN
|
||||||
|
t <- protocol
|
||||||
|
n <- newFieldName
|
||||||
|
dir <- direction
|
||||||
|
sColon
|
||||||
|
eol
|
||||||
|
return (n, A.ChanEnd dir (A.ChanAttributes A.Unshared A.Unshared) t)
|
||||||
|
|
||||||
retypesAbbrev :: OccParser NameSpec
|
retypesAbbrev :: OccParser NameSpec
|
||||||
retypesAbbrev
|
retypesAbbrev
|
||||||
|
@ -1360,6 +1396,8 @@ process
|
||||||
<|> handleSpecs (allocation <|> specification) process
|
<|> handleSpecs (allocation <|> specification) process
|
||||||
(\m s p -> A.Seq m (A.Spec m s (A.Only m p)))
|
(\m s p -> A.Seq m (A.Spec m s (A.Only m p)))
|
||||||
<|> (pragma >> process)
|
<|> (pragma >> process)
|
||||||
|
<|> do {m <- md; sCLAIM; v <- variable; eol; indent; p <- process; outdent;
|
||||||
|
return $ A.Claim m v p }
|
||||||
<?> "process"
|
<?> "process"
|
||||||
|
|
||||||
--{{{ assignment (:=)
|
--{{{ assignment (:=)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user