Skip to content

Commit

Permalink
Change modport separator from . to :: #65
Browse files Browse the repository at this point in the history
  • Loading branch information
dalance committed Jan 16, 2023
1 parent bdbc7b1 commit 1815d7a
Show file tree
Hide file tree
Showing 13 changed files with 2,596 additions and 3,922 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased](https://github.com/dalance/veryl/compare/v0.1.14...Unreleased) - ReleaseDate

* [Changed] modport separator from `.` to `::`

## [v0.1.14](https://github.com/dalance/veryl/compare/v0.1.13...v0.1.14) - 2023-01-12

## [v0.1.13](https://github.com/dalance/veryl/compare/v0.1.12...v0.1.13) - 2023-01-10
Expand Down
6 changes: 0 additions & 6 deletions crates/analyzer/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ impl From<&syntax_tree::Type> for Type {
}
TypeKind::UserDefined(name)
}
syntax_tree::TypeGroup::ModportIdentifier(x) => {
let x = &x.modport_identifier;
let interface = x.identifier.identifier_token.token.text;
let modport = x.identifier0.identifier_token.token.text;
TypeKind::Modport(interface, modport)
}
};
let mut width = Vec::new();
for x in &value.type_list {
Expand Down
1 change: 0 additions & 1 deletion crates/emitter/src/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ impl VerylWalker for Aligner {
match &*arg.type_group {
TypeGroup::BuiltinType(x) => self.builtin_type(&x.builtin_type),
TypeGroup::ScopedIdentifier(x) => self.scoped_identifier(&x.scoped_identifier),
TypeGroup::ModportIdentifier(x) => self.modport_identifier(&x.modport_identifier),
};
let loc = self.aligns[align_kind::TYPE].last_location;
self.aligns[align_kind::TYPE].finish_item();
Expand Down
19 changes: 17 additions & 2 deletions crates/emitter/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Emitter {
in_always_ff: bool,
in_function: bool,
in_generate: bool,
in_direction_modport: bool,
reset_signal: Option<String>,
default_block: Option<String>,
}
Expand All @@ -44,6 +45,7 @@ impl Default for Emitter {
in_always_ff: false,
in_function: false,
in_generate: false,
in_direction_modport: false,
reset_signal: None,
default_block: None,
}
Expand Down Expand Up @@ -222,7 +224,6 @@ impl Emitter {
}
}
TypeGroup::ScopedIdentifier(x) => self.scoped_identifier(&x.scoped_identifier),
TypeGroup::ModportIdentifier(x) => self.modport_identifier(&x.modport_identifier),
}
}

Expand All @@ -239,7 +240,6 @@ impl Emitter {
BuiltinType::F64(_) => true,
},
TypeGroup::ScopedIdentifier(_) => true,
TypeGroup::ModportIdentifier(_) => true,
};
if width {
self.space(1);
Expand Down Expand Up @@ -274,6 +274,19 @@ impl VerylWalker for Emitter {
self.token(arg);
}

/// Semantic action for non-terminal 'ScopedIdentifier'
fn scoped_identifier(&mut self, arg: &ScopedIdentifier) {
self.identifier(&arg.identifier);
for x in &arg.scoped_identifier_list {
if self.in_direction_modport {
self.str(".");
} else {
self.colon_colon(&x.colon_colon);
}
self.identifier(&x.identifier);
}
}

/// Semantic action for non-terminal 'Expression'
fn expression(&mut self, arg: &Expression) {
self.expression01(&arg.expression01);
Expand Down Expand Up @@ -1258,13 +1271,15 @@ impl VerylWalker for Emitter {
PortDeclarationItemGroup::DirectionType(x) => {
self.direction(&x.direction);
if let Direction::Modport(_) = *x.direction {
self.in_direction_modport = true;
} else {
self.space(1);
}
self.r#type_left(&x.r#type);
self.space(1);
self.identifier(&arg.identifier);
self.r#type_right(&x.r#type);
self.in_direction_modport = false;
}
PortDeclarationItemGroup::Interface(x) => {
self.interface(&x.interface);
Expand Down
1 change: 0 additions & 1 deletion crates/formatter/src/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ impl VerylWalker for Aligner {
match &*arg.type_group {
TypeGroup::BuiltinType(x) => self.builtin_type(&x.builtin_type),
TypeGroup::ScopedIdentifier(x) => self.scoped_identifier(&x.scoped_identifier),
TypeGroup::ModportIdentifier(x) => self.modport_identifier(&x.modport_identifier),
};
let loc = self.aligns[align_kind::TYPE].last_location;
self.aligns[align_kind::TYPE].finish_item();
Expand Down
1 change: 0 additions & 1 deletion crates/formatter/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ impl VerylWalker for Formatter {
match &*arg.type_group {
TypeGroup::BuiltinType(x) => self.builtin_type(&x.builtin_type),
TypeGroup::ScopedIdentifier(x) => self.scoped_identifier(&x.scoped_identifier),
TypeGroup::ModportIdentifier(x) => self.modport_identifier(&x.modport_identifier),
};
self.space(1);
for x in &arg.type_list {
Expand Down
15 changes: 0 additions & 15 deletions crates/parser/src/finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,6 @@ impl VerylWalker for Finder {
}
}

/// Semantic action for non-terminal 'ModportIdentifier'
fn modport_identifier(&mut self, arg: &ModportIdentifier) {
self.hit = false;
self.in_group = true;
self.identifier(&arg.identifier);
self.in_group = false;
self.dot(&arg.dot);
self.in_group = true;
self.identifier(&arg.identifier0);
self.in_group = false;
if !self.hit {
self.token_group.clear();
}
}

/// Semantic action for non-terminal 'ExpressionIdentifier'
fn expression_identifier(&mut self, arg: &ExpressionIdentifier) {
self.hit = false;
Expand Down
Loading

0 comments on commit 1815d7a

Please sign in to comment.