Skip to content

Commit d0ef021

Browse files
author
Johannes Zeppenfeld
committed
Store InterfaceListType in InterfaceObjectDeclaration of AST
1 parent 22d967d commit d0ef021

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

vhdl_lang/src/ast.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,13 @@ pub enum ObjectClass {
515515
SharedVariable,
516516
}
517517

518+
#[derive(PartialEq, Debug, Clone, Copy)]
519+
pub enum InterfaceListType {
520+
Port,
521+
Generic,
522+
Parameter,
523+
}
524+
518525
#[derive(PartialEq, Debug, Clone)]
519526
pub struct ObjectDeclaration {
520527
pub class: ObjectClass,
@@ -583,6 +590,7 @@ pub struct InterfaceFileDeclaration {
583590
/// LRM 6.5.2 Interface object declarations
584591
#[derive(PartialEq, Debug, Clone)]
585592
pub struct InterfaceObjectDeclaration {
593+
pub list_type: InterfaceListType,
586594
pub class: ObjectClass,
587595
pub ident: Ident,
588596
pub mode: Mode,

vhdl_lang/src/syntax/interface_declaration.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ fn parse_interface_object_declaration(
144144
.into_iter()
145145
.map(|ident| {
146146
InterfaceDeclaration::Object(InterfaceObjectDeclaration {
147+
list_type,
147148
mode,
148149
class: object_class,
149150
ident,
@@ -258,13 +259,6 @@ fn parse_semicolon_separator(stream: &mut TokenStream) -> ParseResult<()> {
258259
Ok(())
259260
}
260261

261-
#[derive(PartialEq, Clone, Copy)]
262-
enum InterfaceListType {
263-
Port,
264-
Generic,
265-
Parameter,
266-
}
267-
268262
fn is_sync_kind(list_type: InterfaceListType, kind: Kind) -> bool {
269263
matches!(
270264
(list_type, kind),
@@ -405,13 +399,15 @@ mod tests {
405399
code.with_stream_no_diagnostics(parse_generic_interface_list),
406400
vec![
407401
InterfaceDeclaration::Object(InterfaceObjectDeclaration {
402+
list_type: InterfaceListType::Generic,
408403
mode: Mode::In,
409404
class: ObjectClass::Constant,
410405
ident: code.s1("foo").ident(),
411406
subtype_indication: code.s1("natural").subtype_indication(),
412407
expression: None
413408
}),
414409
InterfaceDeclaration::Object(InterfaceObjectDeclaration {
410+
list_type: InterfaceListType::Generic,
415411
mode: Mode::In,
416412
class: ObjectClass::Constant,
417413
ident: code.s1("bar").ident(),
@@ -428,6 +424,7 @@ mod tests {
428424
assert_eq!(
429425
code.with_stream(parse_generic),
430426
InterfaceDeclaration::Object(InterfaceObjectDeclaration {
427+
list_type: InterfaceListType::Generic,
431428
mode: Mode::In,
432429
class: ObjectClass::Constant,
433430
ident: code.s1("foo").ident(),
@@ -479,6 +476,7 @@ mod tests {
479476
assert_eq!(
480477
code.with_stream(parse_port),
481478
InterfaceDeclaration::Object(InterfaceObjectDeclaration {
479+
list_type: InterfaceListType::Port,
482480
mode: Mode::In,
483481
class: ObjectClass::Signal,
484482
ident: code.s1("foo").ident(),
@@ -546,8 +544,8 @@ mod tests {
546544
assert_eq!(
547545
code.with_stream(parse_generic),
548546
InterfaceDeclaration::Object(InterfaceObjectDeclaration {
547+
list_type: InterfaceListType::Generic,
549548
mode: Mode::In,
550-
551549
class: ObjectClass::Constant,
552550
ident: code.s1("foo").ident(),
553551
subtype_indication: code.s1("std_logic").subtype_indication(),
@@ -562,8 +560,8 @@ mod tests {
562560
assert_eq!(
563561
code.with_stream(parse_port),
564562
InterfaceDeclaration::Object(InterfaceObjectDeclaration {
563+
list_type: InterfaceListType::Port,
565564
mode: Mode::In,
566-
567565
class: ObjectClass::Signal,
568566
ident: code.s1("foo").ident(),
569567
subtype_indication: code.s1("std_logic").subtype_indication(),

0 commit comments

Comments
 (0)