Skip to content

Commit

Permalink
Merge pull request #200 from Schottkyc137/include-tokens-in-ast
Browse files Browse the repository at this point in the history
Include tokens in ast
  • Loading branch information
kraigher committed Sep 24, 2023
2 parents 8b717f0 + 8ee2cb2 commit 0c9f487
Show file tree
Hide file tree
Showing 24 changed files with 1,252 additions and 695 deletions.
4 changes: 4 additions & 0 deletions vhdl_lang/src/analysis/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::region::*;
use super::root::*;
use crate::ast::*;
use crate::data::*;
use crate::syntax::TokenAccess;
use fnv::FnvHashSet;
use std::cell::RefCell;
use std::ops::Deref;
Expand Down Expand Up @@ -155,13 +156,15 @@ pub(super) struct AnalyzeContext<'a> {
uses: RefCell<FnvHashSet<UnitId>>,
missing_unit: RefCell<FnvHashSet<(Symbol, Symbol, Option<Symbol>)>>,
uses_library_all: RefCell<FnvHashSet<Symbol>>,
pub ctx: &'a dyn TokenAccess,
}

impl<'a> AnalyzeContext<'a> {
pub fn new(
root: &'a DesignRoot,
current_unit: &UnitId,
arena: &'a Arena,
ctx: &'a dyn TokenAccess,
) -> AnalyzeContext<'a> {
AnalyzeContext {
work_sym: root.symbol_utf8("work"),
Expand All @@ -178,6 +181,7 @@ impl<'a> AnalyzeContext<'a> {
uses: RefCell::new(FnvHashSet::default()),
missing_unit: RefCell::new(FnvHashSet::default()),
uses_library_all: RefCell::new(FnvHashSet::default()),
ctx,
}
}

Expand Down
2 changes: 1 addition & 1 deletion vhdl_lang/src/analysis/declarative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl<'a> AnalyzeContext<'a> {
}

Declaration::Use(ref mut use_clause) => {
self.analyze_use_clause(scope, &mut use_clause.item, diagnostics)?;
self.analyze_use_clause(scope, use_clause, diagnostics)?;
}

Declaration::Package(ref mut instance) => {
Expand Down
18 changes: 11 additions & 7 deletions vhdl_lang/src/analysis/design_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,15 @@ impl<'a> AnalyzeContext<'a> {
pub(crate) fn analyze_context_clause(
&self,
scope: &Scope<'a>,
context_clause: &mut [WithPos<ContextItem>],
context_clause: &mut [ContextItem],
diagnostics: &mut dyn DiagnosticHandler,
) -> FatalResult {
for context_item in context_clause.iter_mut() {
match context_item.item {
ContextItem::Library(LibraryClause { ref mut name_list }) => {
for library_name in name_list.iter_mut() {
match context_item {
ContextItem::Library(LibraryClause {
ref mut name_list, ..
}) => {
for library_name in name_list.items_mut() {
if self.work_sym == library_name.item.item {
library_name.set_unique_reference(self.work_library());
diagnostics.push(Diagnostic::hint(
Expand All @@ -498,8 +500,10 @@ impl<'a> AnalyzeContext<'a> {
ContextItem::Use(ref mut use_clause) => {
self.analyze_use_clause(scope, use_clause, diagnostics)?;
}
ContextItem::Context(ContextReference { ref mut name_list }) => {
for name in name_list.iter_mut() {
ContextItem::Context(ContextReference {
ref mut name_list, ..
}) => {
for name in name_list.items_mut() {
match name.item {
Name::Selected(..) => {}
_ => {
Expand Down Expand Up @@ -556,7 +560,7 @@ impl<'a> AnalyzeContext<'a> {
use_clause: &mut UseClause,
diagnostics: &mut dyn DiagnosticHandler,
) -> FatalResult {
for name in use_clause.name_list.iter_mut() {
for name in use_clause.name_list.items_mut() {
match name.item {
Name::Selected(..) => {}
Name::SelectedAll(..) => {}
Expand Down
2 changes: 1 addition & 1 deletion vhdl_lang/src/analysis/overloaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl<'a> AnalyzeContext<'a> {
}

for elem in assocs.iter_mut() {
clear_references(elem);
clear_references(elem, self.ctx);
}
}

Expand Down
Loading

0 comments on commit 0c9f487

Please sign in to comment.