I believe I've finished the sync parser
This commit is contained in:
parent
db6034db40
commit
405d6ecc55
4
TODO.md
4
TODO.md
|
@ -25,9 +25,11 @@
|
||||||
- [ ] may want to also derive equality statements
|
- [ ] may want to also derive equality statements
|
||||||
- [x] replace both `pEol *> pMaybeWs` and `pEol <* pMaybeWs`
|
- [x] replace both `pEol *> pMaybeWs` and `pEol <* pMaybeWs`
|
||||||
with `pEolAndAdvanceToNextNonWs`
|
with `pEolAndAdvanceToNextNonWs`
|
||||||
|
- [ ] Check inline sequencing of whitespace parsers in do blocks.
|
||||||
|
Terminating instances of `pWs` should be preceeded by `<*`
|
||||||
|
|
||||||
# Parser Development
|
# Parser Development
|
||||||
- [ ] Sync
|
- [x] Sync
|
||||||
- [ ] Process
|
- [ ] Process
|
||||||
- [ ] Module
|
- [ ] Module
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ data CaseBody = CaseBody [CaseBodyVariants] deriving (Show)
|
||||||
|
|
||||||
-- Syncs
|
-- Syncs
|
||||||
data Sync = Sync SyncStmt [UpdateStmt] deriving (Show)
|
data Sync = Sync SyncStmt [UpdateStmt] deriving (Show)
|
||||||
data SyncStmt = SigSpecPredicated SyncType SigSpec
|
data SyncStmt = SigSpecPredicated SigSpec SyncType
|
||||||
| Global
|
| Global
|
||||||
| Init
|
| Init
|
||||||
| Always
|
| Always
|
||||||
|
|
|
@ -330,6 +330,31 @@ pSwitchEndStmt :: Parser ()
|
||||||
pSwitchEndStmt = void (string "end" *> pEolAndAdvanceToNextNonWs)
|
pSwitchEndStmt = void (string "end" *> pEolAndAdvanceToNextNonWs)
|
||||||
|
|
||||||
-- Syncs
|
-- Syncs
|
||||||
|
pSync :: Parser Sync
|
||||||
|
pSync = Sync
|
||||||
|
<$> pSyncStmt
|
||||||
|
<*> many pUpdateStmt
|
||||||
|
|
||||||
|
pSyncStmt :: Parser SyncStmt
|
||||||
|
pSyncStmt = pKeywordSync *>
|
||||||
|
pSigSpecPredicatedSyncStmt <|>
|
||||||
|
pNonSigSpecPredicatedSyncStmt
|
||||||
|
where pKeywordSync = string "sync" *> pWs
|
||||||
|
|
||||||
|
pSigSpecPredicatedSyncStmt :: Parser SyncStmt
|
||||||
|
pSigSpecPredicatedSyncStmt = do
|
||||||
|
syncType <- pSyncType <* pWs
|
||||||
|
sigSpec <- pSigSpec <* pEolAndAdvanceToNextNonWs
|
||||||
|
return $ SigSpecPredicated sigSpec syncType
|
||||||
|
|
||||||
|
pNonSigSpecPredicatedSyncStmt :: Parser SyncStmt
|
||||||
|
pNonSigSpecPredicatedSyncStmt =
|
||||||
|
keyword <* pEolAndAdvanceToNextNonWs
|
||||||
|
where keyword =
|
||||||
|
(Global <$ string "global" ) <|>
|
||||||
|
(Init <$ string "init" ) <|>
|
||||||
|
(Always <$ string "always" )
|
||||||
|
|
||||||
pSyncType :: Parser SyncType
|
pSyncType :: Parser SyncType
|
||||||
pSyncType =
|
pSyncType =
|
||||||
(Low <$ string "low" ) <|>
|
(Low <$ string "low" ) <|>
|
||||||
|
@ -343,7 +368,6 @@ pUpdateStmt = UpdateStmt
|
||||||
<$> (string "update" *> pWs *> pDestSigSpec)
|
<$> (string "update" *> pWs *> pDestSigSpec)
|
||||||
<*> (pWs *> pSrcSigSpec <* pEolAndAdvanceToNextNonWs)
|
<*> (pWs *> pSrcSigSpec <* pEolAndAdvanceToNextNonWs)
|
||||||
|
|
||||||
|
|
||||||
-- would correspond to `123456789[0:9][0:8]`
|
-- would correspond to `123456789[0:9][0:8]`
|
||||||
exampleSigSpecSlice =
|
exampleSigSpecSlice =
|
||||||
SigSpecSlice
|
SigSpecSlice
|
||||||
|
|
Loading…
Reference in a new issue