stopping point8 before repairing parser

This commit is contained in:
Yehowshua Immanuel 2024-12-10 13:35:31 -05:00
parent 3f6a14a59a
commit a02ba006de
2 changed files with 13 additions and 46 deletions

51
TODO.md
View file

@ -12,64 +12,29 @@
- [ ] add validation section to README - [ ] add validation section to README
- [ ] just support Cell memV2 - [ ] just support Cell memV2
- [ ] for value, what happens if we have 0 binary digits - [ ] for value, what happens if we have 0 binary digits
- [ ] modify parser to ignore comments... - should probably wait until
parser is finished before asking
- [ ] modify AST to support src tracking - needed to allow for human - [ ] modify AST to support src tracking - needed to allow for human
readable and correctable validation errors readable and correctable validation errors
- [ ] when writing simulator, must specify directions on cell ports - [ ] when writing simulator, must specify directions on cell ports
- [ ] in the <process>, why are we allowed to have <assign-stmt> before - [ ] track RTLIL EBNF spec vs RTLIL Lex/Yacc implementation
and after the optional <switch> stmt? If the ordering here is [deviation issue][deviation-issue]
semantically significant, then modify AST to only have single - [ ] Update issue above with fact that `<memwr>` is also missing
`[AssignStmt]` field and update parser behavior accordingly.
- [ ] inspect Chris's mini-RTLIL
- [ ] add RST grammar file to repo
- [ ] name parsers so that that we know where failures occured
- [ ] may want to also derive equality statements - [ ] may want to also derive equality statements
- [x] replace both `pEol *> pMaybeWs` and `pEol <* pMaybeWs`
with `pEolAndAdvanceToNextNonWs`
- [x] Check inline sequencing of whitespace parsers in do blocks. - [x] Check inline sequencing of whitespace parsers in do blocks.
Terminating instances of `pWs` should be preceeded by `<*` Terminating instances of `pWs` should be preceeded by `<*`
- [ ] Verify no backtracking needed when sequencing `many` parsers.
Basically, we want to make sure that the argument of the `many`
parser doesn't conflict(exhibit a partial early match) with
the argument of the parser after the argument of the `many` parser.
# Parser Development # Parser Development
- [x] Sync
- [ ] Process
- [x] Finish `pCell` with `pCellEndStmt`
- [ ] Rewrite `pWireStmt` and `pMemoryStmt` using do-notation...
- [x] Remove all instances of `_ <-`
- [ ] Module
- [ ] Remove weird GHC imports - [ ] Remove weird GHC imports
- [ ] Test `fsm1.il` which has recursive slices on line 180
- [ ] Embed locs in AST - [ ] Embed locs in AST
- [ ] Scrap `pEolAndAdvanceToNextNonWs` and use `tok` - [ ] Name new parsers
- [ ] Remove `preProcessDiscardComments` from exports - [ ] Remove `a` and `val` from exports
- [ ] Install README in dir containing `Parser.hs`
- [ ] Discuss deviations of parser against Yosys behaviors
- [x] Are the `try` statements in `pWireOption` correctly constructed?
- [ ] Consider the very weird case where the process body has nothing,
thus, `pEolAndAdvanceToNextNonWs` may never get invoked in any of
the sub-parsers encapsulated in `pProcessBody`. Do we need to
advance whitespaces so we can hit `<proc-end-stmt>`?
- [ ] What are the implications for other parsers?
I think that in this case we're OK as `<proc-stmt>` necessarily
precedes `<process-body>` and `<proc-stmt>` terminates in an EOL
parser that advances to the next non-whitespace.
I still need to verify how other parsers behave. For example, what
happens if we have a cell with no `<cell-body-stmt>`
# Parser Verification # Parser Verification
- [ ] I think only EOL terminated parsers should be responsible - [ ] I think only EOL terminated parsers should be responsible
for advancing the Parsec scanner to the next non-space... for advancing the Parsec scanner to the next token
- [ ] lift grammar into prover and show that all EOL terminated parsers - [ ] lift grammar into prover and show that all EOL terminated parsers
are either followed by EOF or a keyword such "module", "autoidx", are either followed by EOF or a keyword such "module", "autoidx",
etc etc
- [ ] first, manually inspect switch parser and try and see if it
can infinitely recurse... Then empirically validate against
corpus
# Simulation Behavior # Simulation Behavior
- [ ] Figure out the computational semantics of what it means to - [ ] Figure out the computational semantics of what it means to
@ -83,3 +48,5 @@
# Optimizations # Optimizations
- [ ] squeeze out recursive slices - [ ] squeeze out recursive slices
[deviation-issue]: https://github.com/YosysHQ/yosys/issues/4811

View file

@ -67,11 +67,9 @@ import RTLILParser.Primitives(
-- taken from: https://yosyshq.readthedocs.io/projects/yosys/en/0.47/appendix/rtlil_text.html -- taken from: https://yosyshq.readthedocs.io/projects/yosys/en/0.47/appendix/rtlil_text.html
-- parsers below are split int sections from the above link -- parsers below are split int sections from the above link
runParser str = case parse pFile "pFile" preProcessedFile of runParser str = case parse pFile "pFile" str of
-- runParser str = case parse pCell "pCell" preProcessedFile of
Left err -> error $ show err Left err -> error $ show err
Right val -> val Right val -> val
where preProcessedFile = str
-- identifiers -- identifiers
pId :: Parser Id pId :: Parser Id
@ -305,6 +303,8 @@ pWireOption :: Parser WireOption
pWireOption = p <?> name where pWireOption = p <?> name where
name = "WireOption" name = "WireOption"
p = p =
-- We technically don't need the first `try` below so this is a
-- stylistic choice. The other `try` statements are needed.
try (WireOptionWidth <$> (string "width" *> pWs *> pInteger)) <|> try (WireOptionWidth <$> (string "width" *> pWs *> pInteger)) <|>
try (WireOptionOffset <$> (string "offset" *> pWs *> pInteger)) <|> try (WireOptionOffset <$> (string "offset" *> pWs *> pInteger)) <|>
try (WireOptionInput <$> (string "input" *> pWs *> pInteger)) <|> try (WireOptionInput <$> (string "input" *> pWs *> pInteger)) <|>