Comments (5)
I'm trying to get my head around how a semantic pass might go.
-
Step through the AST of a design unit.
-
A DeclarativeRegion structure keeps track of what symbols have been declared in this region so far.
-
As we process declarations we add the new symbols to the Declarative Region.
-
As we process symbol uses we check if the symbols have already been declared in this region. If they haven't we check in parent regions recursively. If the declaration is present in this design unit we link the use of the symbol to it's declaration. If the declaration is not present we add it to a set of unresolved symbols along with the set of packages that were in scope at the time of use.
-
Step through all design units
-
Go back to each design unit and resolve the unresolved symbols. Identify circular dependencies. Link symbol uses with their declarations in appropriate packages. Identify ambiguous symbol uses.
Is this the general direction you were thinking?
At the moment it looks like the semantic analysis is making sure declarations are consistent with one another but hasn't worried about symbol uses yet. Is that correct?
from rust_hdl.
My current thinking is:
- Traverse the entire AST and build DeclarativeRegions. The DeclarativeRegions only live temporarily in this pass and are thrown away afterwards. Public declarative regions such as in packages which might be saved for later use.
- Desing units are only analyzed once and will be analyzed on-demand (See 2. in #7)
- Check for duplicate declarations as you go.
- DONE
- Check some rules regarding protected type declaration/body deferred constant and incomplete type when a region is complete.
- DONE
- Check for missing declarations in all names and use clauses.
- Partially done for use clauses, this is the next step
The there are two options to proceed:
- Annotate back to the AST (by mutating it) the multiple potential references for each name and perform type checking in a separate pass.
- Perform type checking in the same pass and write back to the AST the single resolved reference.
Also note that I use a Test-Driven-Development workflow which means I have an idea of where I want to go but I do not go ahead and build everything I think I will need without having tests that require it. Thus the current implementation may have shortcomings compared to my final intention since I have not defined the test cases that require the final intention. This is also the reason I have been holding off adding new fields to the AST since I want tests to require it and I do not want to make premature changes to the parsed AST (which is well understood by me) with semantic information (where I am stilll building my mental model of how it will work).
My strategy is also to develop the semantic analysis such that the example project always continues to work without errors. This means I will try not to implement partial solutions that will cause false errors but rather partial solutions that produce false positives. In this way the language server will never be unusable and provide incrementally more value until it is "complete".
from rust_hdl.
OK. So when we hit a "use work.mypkg.all", we pause the analysis of the design unit, and go and parse the appropriate package. Similarly if we hit a "myblah: entity work.blah" we pause the analysis, and go and parse that entity. This allows the semantic analysis to be done in a single pass, but reduces the possibility for parallelism. Is this implemented already? I didn't see it there.
from rust_hdl.
The on-demand analysis is implemented in my local repository. I will most likely push it today. This method will still allow enough parallelism. You can always start analysis for many design units in parallel and use locking to avoid duplicate analysis or race conditions. Only sequential dependencies would not get analysed in parallel due to locking but for large projects where parallel speed matters the dependency graph has high fan-out so there should be plenty of non-serial dependencies.
from rust_hdl.
I pushed the first version of the on-demand analysis now.
from rust_hdl.
Related Issues (20)
- 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
- [BUG] File paths with $ are incorrectly being interpreted as environment variables HOT 2
- Support for VHDL-2019
- Autocompletion in concurrent statements broken (VSCode) HOT 4
- Signal of record type connected to input/output port of same record type reports a mismatch HOT 3
- Unused lint not available in vhdl_lang HOT 3
- Configurable lint settings for third party libraries HOT 3
- VHDL-LS does not appear in the Mason LSP list when searching for VHDL HOT 1
- Neovim on Mac OS cannot find vhdl_library exception and VHDL LS doesn't function HOT 2
- Adding autoformatting HOT 5
- [BUG] Warning reported regarding unused generic procedures/functions HOT 2
- [Clarification] No warning reported if object is not set HOT 2
- Panic when (seemingly) completing a port name HOT 8
- [Bug] Packages can't explicitly reference themselves HOT 1
- [Bug] Warning reported regarding relational operators HOT 4
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.