-
Notifications
You must be signed in to change notification settings - Fork 177
Specification syntax examples rejected by current parser implementation. #890
Comments
Yeah, we gave up supporting the inline syntax, but haven't updated the documentation. You can go ahead and continue your implementation assuming chisel won't generate any inline syntax. I'm not sure I have time at the moment to update the spec, but I'd certainly merge a PR if you were willing to contribute! What language are you writing the parser for? |
Oh wow. Okay, glad I asked!
Will do. Is there anything else I should know? I don't trust the specification now for obvious reasons.
I'm very happy to contribute. I'm short on time as well, but a lot of my future work will depend on tools like this, so it's a good investment. I can try and re-write the spec to remove references to the in-line syntax, but it will need very thorough review by yourself or some other member of the chissel developers. Any change will require corrections to the concrete syntax specification as well, since it is missing Specifications are the most important part of projects like this, so keeping them up to date has got to be a priority, but I'm not necessarily the most qualified to do it. I'll see how I go.
I haven't decided yet. Its very much a hobby project until I get it to a usable state. Probably something like Python. |
We definitely need to do a better job of it
Have you thought about using ANTLR to generate a Python parser? Support for Java, Python, and C++ are why we originally used ANTLR as a parser generator. I should note that while we still use the Parser, for performance reasons (primarily memory use) we have been moving toward a Protocol Buffer message-based implementation. See .proto file. This information also needs to be added to the spec. |
We'll, I've forked FIRRTL and have a wierd interest in specifications. So I'll have a go at removing references to the inline syntax and updating what the current parser does (using your current ANTLR one as a golden reference). I'll reference this issue in the pull request as well.
Yes that is one option I've been considering. The upside being that the set of acceptable inputs to the parser is guaranteed to be identical to the SCALA implementation. The other option was a clean-room implementation from the spec using the lark-parser which is a really nice (IMHO) pure python library. The advantage there being that it is all python, and there is no need to ship around so much generated code. I think that given this discussion, ANTLR will be the way to go. The most important thing for any FIRRTL parser will be "if it parses for you it will also parse for me".
That's interesting! I've not come across that before. Is it simply a fast way to stream data from say the Chissel back-end into an FIRRTL front-end without going via a file? I can see from the spec that FIRRTL will be a pretty verbose way of expressing even medium size designs, though it is very ammenable to compression if you consider a binary file format. That's probably getting very far ahead though ;) |
That library does look really slick. I definitely think that using the ANTLR library as a starting point is the right way to go and a much lower barrier to entry. Perhaps some day it would make sense to migrate to that but at least in the near term it should be fairly straight forward to get stuff working using ANTLR!
It's kind of orthogonal from whether or not a file is involved. For example, We decided to use ProtoBuf because it was suggested and it seems to have a lot of advantages over other (de)serialization formats like speed, making it easy (and default behavior) to maintain forward and backwards compatibility, etc. The straw that broke the camels back though was the ANTLR parser has some performance cliff for very large designs that I wasn't able to debug. I don't think that's something for you to worry about at the moment, but just be aware. |
* Merge makefile changes from dev/specification-fixes - New top level makefile target: `specification` - Builds the specification document. * Number all code examples. This is more a change of convenience than anything. Referring to syntax examples is much easier when they are numbered! This commit is in the context of #890 - Updating examples and syntax specification is made easier if they are numbered. - Change `verbatim` environments to `lstlisting` - Add very basic keyword highlighting. - Rebuild specification PDF. On branch dev/number-code-examples Changes to be committed: modified: spec/spec.pdf modified: spec/spec.tex
* Merge makefile changes from dev/specification-fixes - New top level makefile target: `specification` - Builds the specification document. * Number all code examples. This is more a change of convenience than anything. Referring to syntax examples is much easier when they are numbered! This commit is in the context of #890 - Updating examples and syntax specification is made easier if they are numbered. - Change `verbatim` environments to `lstlisting` - Add very basic keyword highlighting. - Rebuild specification PDF. On branch dev/number-code-examples Changes to be committed: modified: spec/spec.pdf modified: spec/spec.tex (cherry picked from commit 29e5c08)
* Merge makefile changes from dev/specification-fixes - New top level makefile target: `specification` - Builds the specification document. * Number all code examples. This is more a change of convenience than anything. Referring to syntax examples is much easier when they are numbered! This commit is in the context of chipsalliance/firrtl#890 - Updating examples and syntax specification is made easier if they are numbered. - Change `verbatim` environments to `lstlisting` - Add very basic keyword highlighting. - Rebuild specification PDF. On branch dev/number-code-examples Changes to be committed: modified: spec/spec.pdf modified: spec/spec.tex
Type of issue: bug report
According to the current specification document in the repository, line 6 of the example is valid syntax. See section 12, page 51 - "Details about syntax" where the spec says that
860e6844708e4b87ced04bcef0eda7810cba106a
(HEAD As of Date: Thu Sep 13 22:09:18 2018 -0700)What is the use case for changing the behavior?
The parser does not match the specification. Other implementations of an FIRRTL parser will behave differently.
Impact: unknown
Development Phase: request
Other Information
I have played with lots of toy examples for FIRRTL syntax with the aim of building my own parser for it. However, the current specification does not match the implementation so I can't progress. It looks like the current implementation does not support any of the one-line syntax correctly, only the block/indent syntax. Is this expected?
There are a bunch of ambiguities in the syntax specification as well, such as whether one can break out one one-line syntax and into indented syntax. One line syntax with commas is also completely absent from the concrete syntax tree. I don't know whether this or a new issue is the best place to discuss these problems?
Cheers,
Ben
The text was updated successfully, but these errors were encountered: