This commit is contained in:
dalance 2019-08-12 02:33:23 +09:00
parent 81b8ab7718
commit 377fa5bd42
3 changed files with 42 additions and 26 deletions

View File

@ -215,11 +215,27 @@ pub(crate) fn enum_name_declaration(s: Span) -> IResult<Span, EnumNameDeclaratio
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn class_scope(s: Span) -> IResult<Span, ClassScope> { pub(crate) fn class_scope(s: Span) -> IResult<Span, ClassScope> {
let (s, a) = class_type(s)?; let (s, a) = class_type_class_scope(s)?;
let (s, b) = symbol("::")(s)?; let (s, b) = symbol("::")(s)?;
Ok((s, ClassScope { nodes: (a, b) })) Ok((s, ClassScope { nodes: (a, b) }))
} }
#[tracable_parser]
#[packrat_parser]
pub(crate) fn class_type_class_scope(s: Span) -> IResult<Span, ClassType> {
let (s, a) = ps_class_identifier(s)?;
let (s, b) = opt(parameter_value_assignment)(s)?;
let (s, c) = many0(terminated(
triple(
symbol("::"),
class_identifier,
opt(parameter_value_assignment),
),
peek(symbol("::")),
))(s)?;
Ok((s, ClassType { nodes: (a, b, c) }))
}
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn class_type(s: Span) -> IResult<Span, ClassType> { pub(crate) fn class_type(s: Span) -> IResult<Span, ClassType> {

View File

@ -87,7 +87,7 @@ pub(crate) fn tf_port_item(s: Span) -> IResult<Span, TfPortItem> {
let (s, e) = opt(triple( let (s, e) = opt(triple(
port_identifier, port_identifier,
many0(variable_dimension), many0(variable_dimension),
opt(pair(symbol(":"), expression)), opt(pair(symbol("="), expression)),
))(s)?; ))(s)?;
Ok(( Ok((
s, s,
@ -108,7 +108,7 @@ pub(crate) fn data_type_or_implicit_tf_port_item(s: Span) -> IResult<Span, DataT
opt(triple( opt(triple(
port_identifier, port_identifier,
many0(variable_dimension), many0(variable_dimension),
opt(pair(symbol(":"), expression)), opt(pair(symbol("="), expression)),
)), )),
alt((symbol(","), symbol(")"))), alt((symbol(","), symbol(")"))),
)), )),
@ -122,7 +122,7 @@ pub(crate) fn data_type_or_implicit_tf_port_item(s: Span) -> IResult<Span, DataT
opt(triple( opt(triple(
port_identifier, port_identifier,
many0(variable_dimension), many0(variable_dimension),
opt(pair(symbol(":"), expression)), opt(pair(symbol("="), expression)),
)), )),
alt((symbol(","), symbol(")"))), alt((symbol(","), symbol(")"))),
)), )),

View File

@ -2469,17 +2469,17 @@ mod spec {
r##"initial $display (p.ERR_OVERFLOW);"##, r##"initial $display (p.ERR_OVERFLOW);"##,
Ok((_, _)) Ok((_, _))
); );
//test!( test!(
// many1(module_item), many1(module_item),
// r##"class vector #(parameter width = 7, type T = int); r##"class vector #(parameter width = 7, type T = int);
// endclass endclass
// vector #(3) v = new; vector #(3) v = new;
// initial $display (vector #(3)::T'(3.45)); // Typecasting initial $display (vector #(3)::T'(3.45)); // Typecasting
// initial $display ((v.T)'(3.45)); //ILLEGAL initial $display ((v.T)'(3.45)); //ILLEGAL
// initial $display (v.width);"##, initial $display (v.width);"##,
// Ok((_, _)) Ok((_, _))
//); );
test!( test!(
many1(module_item), many1(module_item),
r##"Packet p = new; r##"Packet p = new;
@ -2530,17 +2530,17 @@ mod spec {
r##"Packet p = new(STARTUP, $random, $time);"##, r##"Packet p = new(STARTUP, $random, $time);"##,
Ok((_, _)) Ok((_, _))
); );
//test!( test!(
// many1(module_item), many1(module_item),
// r##"class c; r##"class c;
// function new(int cmd = IDLE, bit[12:0] adrs = 0, int cmd_time ); function new(int cmd = IDLE, bit[12:0] adrs = 0, int cmd_time );
// command = cmd; command = cmd;
// address = adrs; address = adrs;
// time_requested = cmd_time; time_requested = cmd_time;
// endfunction endfunction
// endclass"##, endclass"##,
// Ok((_, _)) Ok((_, _))
//); );
//test!( //test!(
// many1(module_item), // many1(module_item),
// r##"class C; endclass // r##"class C; endclass
@ -15503,7 +15503,7 @@ mod spec {
fn debug() { fn debug() {
test!( test!(
many1(module_item), many1(module_item),
r##"always_comb d <= #1ns b & c;"##, r##"function a(int cmd = IDLE, bit[12:0] adrs = 0, int cmd_time ); endfunction"##,
Ok((_, _)) Ok((_, _))
); );
} }