Skip to content

Commit

Permalink
Chagne inst syntax #27
Browse files Browse the repository at this point in the history
  • Loading branch information
dalance committed Jan 10, 2023
1 parent bd1b912 commit c9a4339
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions book/src/02_quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ module ModuleA #(
// module instantiation
inst u_module_b: ModuleB #(
) {
};
) (
);
// interface instantiation
inst u_interface_a: InterfaceA;
Expand Down
4 changes: 2 additions & 2 deletions crates/emitter/src/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@ impl VerylWalker for Aligner {
self.inst_parameter(&x.inst_parameter);
}
if let Some(ref x) = arg.inst_declaration_opt1 {
self.l_brace(&x.l_brace);
self.l_paren(&x.l_paren);
if let Some(ref x) = x.inst_declaration_opt2 {
self.inst_port_list(&x.inst_port_list);
}
self.r_brace(&x.r_brace);
self.r_paren(&x.r_paren);
}
self.semicolon(&arg.semicolon);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/emitter/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,13 +982,13 @@ impl VerylWalker for Emitter {
}
self.space(1);
if let Some(ref x) = arg.inst_declaration_opt1 {
self.token_will_push(&x.l_brace.l_brace_token.replace("("));
self.token_will_push(&x.l_paren.l_paren_token.replace("("));
self.newline_push();
if let Some(ref x) = x.inst_declaration_opt2 {
self.inst_port_list(&x.inst_port_list);
}
self.newline_pop();
self.token(&x.r_brace.r_brace_token.replace(")"));
self.token(&x.r_paren.r_paren_token.replace(")"));
} else {
self.str("()");
}
Expand Down
4 changes: 2 additions & 2 deletions crates/formatter/src/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,11 @@ impl VerylWalker for Aligner {
self.inst_parameter(&x.inst_parameter);
}
if let Some(ref x) = arg.inst_declaration_opt1 {
self.l_brace(&x.l_brace);
self.l_paren(&x.l_paren);
if let Some(ref x) = x.inst_declaration_opt2 {
self.inst_port_list(&x.inst_port_list);
}
self.r_brace(&x.r_brace);
self.r_paren(&x.r_paren);
}
self.semicolon(&arg.semicolon);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/formatter/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,13 @@ impl VerylWalker for Formatter {
}
if let Some(ref x) = arg.inst_declaration_opt1 {
self.space(1);
self.token_will_push(&x.l_brace.l_brace_token);
self.token_will_push(&x.l_paren.l_paren_token);
self.newline_push();
if let Some(ref x) = x.inst_declaration_opt2 {
self.inst_port_list(&x.inst_port_list);
}
self.newline_pop();
self.r_brace(&x.r_brace);
self.r_paren(&x.r_paren);
}
self.semicolon(&arg.semicolon);
self.single_line = false;
Expand Down
2 changes: 1 addition & 1 deletion crates/parser/src/generated/veryl-exp.par
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@
/* 457 */ StructListOpt /* Option<T>::None */: ;
/* 458 */ StructItem: Identifier Colon Type;
/* 459 */ InstDeclaration: Inst Identifier Colon Identifier InstDeclarationOpt /* Option */ InstDeclarationOpt0 /* Option */ InstDeclarationOpt1 /* Option */ Semicolon;
/* 460 */ InstDeclarationOpt1 /* Option<T>::Some */: LBrace InstDeclarationOpt2 /* Option */ RBrace;
/* 460 */ InstDeclarationOpt1 /* Option<T>::Some */: LParen InstDeclarationOpt2 /* Option */ RParen;
/* 461 */ InstDeclarationOpt2 /* Option<T>::Some */: InstPortList;
/* 462 */ InstDeclarationOpt2 /* Option<T>::None */: ;
/* 463 */ InstDeclarationOpt1 /* Option<T>::None */: ;
Expand Down
18 changes: 9 additions & 9 deletions crates/parser/src/generated/veryl_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5017,9 +5017,9 @@ pub struct InstDeclarationOpt0 {
#[derive(Builder, Debug, Clone)]
#[builder(crate = "parol_runtime::derive_builder")]
pub struct InstDeclarationOpt1 {
pub l_brace: Box<LBrace>,
pub l_paren: Box<LParen>,
pub inst_declaration_opt2: Option<Box<InstDeclarationOpt2>>,
pub r_brace: Box<RBrace>,
pub r_paren: Box<RParen>,
}

///
Expand Down Expand Up @@ -19668,26 +19668,26 @@ impl<'t, 'u> VerylGrammarAuto<'t, 'u> {

/// Semantic action for production 460:
///
/// InstDeclarationOpt1 /* Option<T>::Some */: LBrace InstDeclarationOpt2 /* Option */ RBrace;
/// InstDeclarationOpt1 /* Option<T>::Some */: LParen InstDeclarationOpt2 /* Option */ RParen;
///
#[parol_runtime::function_name::named]
fn inst_declaration_opt1_0(
&mut self,
_l_brace: &ParseTreeStackEntry<'t>,
_l_paren: &ParseTreeStackEntry<'t>,
_inst_declaration_opt2: &ParseTreeStackEntry<'t>,
_r_brace: &ParseTreeStackEntry<'t>,
_r_paren: &ParseTreeStackEntry<'t>,
_parse_tree: &Tree<ParseTreeType<'t>>,
) -> Result<()> {
let context = function_name!();
trace!("{}", self.trace_item_stack(context));
let r_brace = pop_item!(self, r_brace, RBrace, context);
let r_paren = pop_item!(self, r_paren, RParen, context);
let inst_declaration_opt2 =
pop_item!(self, inst_declaration_opt2, InstDeclarationOpt2, context);
let l_brace = pop_item!(self, l_brace, LBrace, context);
let l_paren = pop_item!(self, l_paren, LParen, context);
let inst_declaration_opt1_0_built = InstDeclarationOpt1Builder::default()
.l_brace(Box::new(l_brace))
.l_paren(Box::new(l_paren))
.inst_declaration_opt2(inst_declaration_opt2)
.r_brace(Box::new(r_brace))
.r_paren(Box::new(r_paren))
.build()
.into_diagnostic()?;
self.push(
Expand Down
32 changes: 16 additions & 16 deletions crates/parser/src/generated/veryl_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12784,8 +12784,8 @@ pub const LOOKAHEAD_AUTOMATA: &[LookaheadDFA; 436] = &[
states: &[None, Some(466), Some(467)],
transitions: &[
DFATransition(0, 34, 2),
DFATransition(0, 35, 2),
DFATransition(0, 36, 1),
DFATransition(0, 37, 2),
DFATransition(0, 41, 2),
],
k: 1,
Expand All @@ -12795,21 +12795,21 @@ pub const LOOKAHEAD_AUTOMATA: &[LookaheadDFA; 436] = &[
states: &[None, Some(464), Some(465)],
transitions: &[
DFATransition(0, 34, 1),
DFATransition(0, 35, 2),
DFATransition(0, 37, 2),
DFATransition(0, 41, 2),
],
k: 1,
},
/* 205 - "InstDeclarationOpt1" */
LookaheadDFA {
states: &[None, Some(460), Some(463)],
transitions: &[DFATransition(0, 35, 1), DFATransition(0, 41, 2)],
transitions: &[DFATransition(0, 37, 1), DFATransition(0, 41, 2)],
k: 1,
},
/* 206 - "InstDeclarationOpt2" */
LookaheadDFA {
states: &[None, Some(461), Some(462)],
transitions: &[DFATransition(0, 38, 2), DFATransition(0, 85, 1)],
transitions: &[DFATransition(0, 40, 2), DFATransition(0, 85, 1)],
k: 1,
},
/* 207 - "InstParameter" */
Expand Down Expand Up @@ -12868,15 +12868,15 @@ pub const LOOKAHEAD_AUTOMATA: &[LookaheadDFA; 436] = &[
DFATransition(4, 29, 3),
DFATransition(4, 40, 3),
DFATransition(5, 5, 8),
DFATransition(5, 35, 9),
DFATransition(5, 37, 9),
DFATransition(5, 41, 10),
DFATransition(6, 5, 7),
DFATransition(6, 35, 7),
DFATransition(6, 37, 7),
DFATransition(6, 41, 7),
DFATransition(8, 35, 7),
DFATransition(8, 37, 7),
DFATransition(8, 41, 7),
DFATransition(9, 5, 7),
DFATransition(9, 38, 7),
DFATransition(9, 40, 7),
DFATransition(9, 85, 7),
DFATransition(10, 5, 7),
DFATransition(10, 28, 7),
Expand Down Expand Up @@ -12919,7 +12919,7 @@ pub const LOOKAHEAD_AUTOMATA: &[LookaheadDFA; 436] = &[
transitions: &[
DFATransition(0, 28, 1),
DFATransition(0, 29, 2),
DFATransition(0, 38, 2),
DFATransition(0, 40, 2),
],
k: 1,
},
Expand All @@ -12945,16 +12945,16 @@ pub const LOOKAHEAD_AUTOMATA: &[LookaheadDFA; 436] = &[
],
transitions: &[
DFATransition(0, 29, 1),
DFATransition(0, 38, 5),
DFATransition(0, 40, 5),
DFATransition(1, 5, 2),
DFATransition(1, 38, 6),
DFATransition(1, 40, 6),
DFATransition(1, 85, 4),
DFATransition(2, 38, 7),
DFATransition(2, 40, 7),
DFATransition(2, 85, 3),
DFATransition(4, 5, 3),
DFATransition(4, 28, 3),
DFATransition(4, 29, 3),
DFATransition(4, 38, 3),
DFATransition(4, 40, 3),
DFATransition(5, 5, 8),
DFATransition(5, 41, 9),
DFATransition(6, 5, 7),
Expand All @@ -12980,7 +12980,7 @@ pub const LOOKAHEAD_AUTOMATA: &[LookaheadDFA; 436] = &[
/* 218 - "InstPortListOpt" */
LookaheadDFA {
states: &[None, Some(482), Some(483)],
transitions: &[DFATransition(0, 29, 1), DFATransition(0, 38, 2)],
transitions: &[DFATransition(0, 29, 1), DFATransition(0, 40, 2)],
k: 1,
},
/* 219 - "InstTerm" */
Expand Down Expand Up @@ -19585,10 +19585,10 @@ pub const PRODUCTIONS: &[Production; 602] = &[
ParseType::N(201),
],
},
// 460 - InstDeclarationOpt1: LBrace InstDeclarationOpt2 /* Option */ RBrace;
// 460 - InstDeclarationOpt1: LParen InstDeclarationOpt2 /* Option */ RParen;
Production {
lhs: 205,
production: &[ParseType::N(350), ParseType::N(206), ParseType::N(239)],
production: &[ParseType::N(356), ParseType::N(206), ParseType::N(245)],
},
// 461 - InstDeclarationOpt2: InstPortList;
Production {
Expand Down
4 changes: 2 additions & 2 deletions crates/parser/src/veryl_walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,11 +1348,11 @@ pub trait VerylWalker {
self.inst_parameter(&x.inst_parameter);
}
if let Some(ref x) = arg.inst_declaration_opt1 {
self.l_brace(&x.l_brace);
self.l_paren(&x.l_paren);
if let Some(ref x) = x.inst_declaration_opt2 {
self.inst_port_list(&x.inst_port_list);
}
self.r_brace(&x.r_brace);
self.r_paren(&x.r_paren);
}
self.semicolon(&arg.semicolon);
after!(self, inst_declaration, arg);
Expand Down
2 changes: 1 addition & 1 deletion crates/parser/veryl.par
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ StructItem: Identifier Colon Type;
// InstDeclaration
// ----------------------------------------------------------------------------

InstDeclaration: Inst Identifier Colon Identifier [ Width ] [ InstParameter ] [ LBrace [ InstPortList ] RBrace ] Semicolon;
InstDeclaration: Inst Identifier Colon Identifier [ Width ] [ InstParameter ] [ LParen [ InstPortList ] RParen ] Semicolon;

InstParameter: Hash LParen [ InstParameterList ] RParen;

Expand Down
4 changes: 2 additions & 2 deletions testcases/vl/14_inst.vl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ module Module14 {
a ,
aa: 10 ,
aa: 100,
) {
) (
a ,
bb : aa ,
bbbb: bbb,
};
);

// interface instantiation
inst y: InterfaceA;
Expand Down

0 comments on commit c9a4339

Please sign in to comment.