Comments (7)
I had naively started to implement (1) but I like your solution (3) much better. I'll let you know once I've got something worth looking at.
from rust_hdl.
Thinking about how to deal with comments at the end of the file. There won't be a token that it makes sense to associate them with. I'll just create a FinalComment token. Since this can only occur in one place, the parsing change will be minor.
from rust_hdl.
I've been thinking about this some more (and trying to take the next step to moving the comments from the tokens to the AST) and I'm not happy about how I have implemented it so far. In the current implementation I assigned all comments to a token. Most positions don't make any sense and we need to gather up all those comments to either move them or emit warnings for them. This gathering gets messy.
I would like to remove the comments from the tokens and implement the following methods on the Tokenizer:
// Gets the leading comments for the next token.
pub fn get_leading_comments(&mut self) -> Vec(Comment);
// Gets the trailing comment for the previous token.
pub fn get_trailing_comment(&mut self) -> Option(Comment);
// Returns a vector of all the comments that were parsed since we last
// handled. Does not include comments that were
// retrieved using get_leading_comments or get_trailing_comment. This
// is useful if we wish to move all these comments to a new location or to
// generate warning messages from them.
pub fn handle_new_comments(&mut self) -> Vec(Comment);
So if we were parsing a type_definition:
- Assert that there aren't any already parsed comments that haven't been handled.
- Get the leading comments for the definition.
- Parse the definition.
- Get the trailing comment.
- Get the comments that weren't handled. Either combine them into the other comments, or ignore them. Generate warning messages either way.
- Add the combined comment (probably a latin_1_str) into the type_definition object.
The main complexity is dealing with set_state
since that should modify the vector of unhandled comments. We could replace set_state
with move_backwards
which just drops any unhandled comments from the list if their position is ahead of the new state. The other main use of set_state
is in move_after(token)
which seems to be exclusively used for moving after a peeked token. This could be replaced with move_after_peek()
which just moves after the token previously peeked. The state and unhandled comments could be stored in the Tokenizer whenever a peek is performed.
Does this seem like a reasonable approach?
from rust_hdl.
I agree with the approach.
from rust_hdl.
I've reworked the comment parsing along these lines in #30.
I'm still working on improving the tests and getting the comments into the AST.
from rust_hdl.
@benreynwar what has happened with the PR, what is the current status?
from rust_hdl.
It's abandoned. I'm trying to focus my 'fun work' time on ghdl now.
from rust_hdl.
Related Issues (20)
- re-start error
- Attribute specification must be in the immediate declarative HOT 4
- Incorrect diagnostic for attributes
- No declaration within package instance
- Selected names from 'unusual' places HOT 1
- The project name 'rust_hdl' doesn't reflect its purpose of being a language server for VHDL HOT 1
- [Issue] No primary unit 'INST_NAME' within library 'work' HOT 7
- Re-defined library HOT 3
- [BUG] Errors reported when using attribute (subtype) on indexed array HOT 5
- [FEATURE] Add exclusion list for problems panel HOT 4
- [BUG] Function override error with types "std_logic_vector" and "std_ulogic_vector" HOT 2
- [FEATURE] Fetch/autocomplete the external name path of an object/signal
- Enhancement: Improve cyclic dependency check to allow recursive instantiation HOT 1
- [Feature Request] Recursive Symbol Hover extraction
- In the readme.md add a description how to install VHDL_LS for Neovim HOT 1
- Error in `float_generic_pkg-body.vhd`
- Generic Library Inclusion HOT 2
- Getting errors for `ieee2008/float_generic_pkg-body.vhdl` HOT 3
- Support for VHDL-2019 HOT 2
- [Issue] Support for incremental sync HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust_hdl.