Skip to content

Commit

Permalink
src, test: Add optional QSTRING to p_cond_def.
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrej.ille committed Aug 26, 2024
1 parent 73ab740 commit c3dc17a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/sdf/sdf-node.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static const imask_t has_map[S_LAST_NODE_KIND] = {
(I_IDENT | I_LITERALS | I_FLAGS),

// S_COND
(I_VALUE),
(I_IDENT | I_VALUE),

// S_PORT
(I_SUBKIND | I_IDENT | I_DIMS | I_FLAGS | I_VALUE),
Expand Down
11 changes: 7 additions & 4 deletions src/sdf/sdf-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,16 @@ static ident_t p_identifier(void)
return error_marker();
}

// TODO: How is it with the surrounding apostrophes ? Are they stripped ?
static ident_t p_qstring(void)
{
// qstring ::=
// " { any_character } "

BEGIN("qstring");

// Qstring identifier is stored including the surrounding
// apostrophes.

// TODO: Check how is tSTRING handled in lexer. Right now it re-uses VHDL string.
// I am not sure if it is defined equally!
consume(tSTRING);
Expand Down Expand Up @@ -1157,8 +1159,8 @@ static void p_name(sdf_node_t constr)
consume(tLPAREN);
consume(tNAME);

// TODO: qstring should be optional!
sdf_set_ident(constr, p_qstring());
if (scan(tSTRING))
sdf_set_ident(constr, p_qstring());

consume(tRPAREN);
}
Expand Down Expand Up @@ -1929,7 +1931,8 @@ static void p_cond_def(sdf_node_t delay)

sdf_node_t cond = sdf_new(S_COND);

// TODO: Add optional qstring here!
if (scan(tSTRING))
sdf_set_ident(cond, p_qstring());

sdf_set_expr(cond, p_conditional_port_expr());
sdf_add_cond(delay, cond);
Expand Down
2 changes: 1 addition & 1 deletion test/sdf/parse16.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(DELAY
(ABSOLUTE
(COND i_and.b==1'b0 (IOPATH i_and.a i_and.y (0.5) ))
(COND i_and.b=='b1 (IOPATH i_and.a i_and.y (0.4) ))
(COND "My condition name" i_and.b=='b1 (IOPATH i_and.a i_and.y (0.4) ))
)
)
)
Expand Down
2 changes: 2 additions & 0 deletions test/test_sdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,8 @@ START_TEST(test_sdf16)
fail_unless(icmp(sdf_ident(sdf_port(d_1, 1)), "i_and.y"));

sdf_node_t d_1_c_0 = sdf_cond(d_1, 0);
fail_unless(icmp(sdf_ident(d_1_c_0), "\"My condition name\""));

sdf_node_t d_1_c_0_e_0 = sdf_expr(d_1_c_0);
fail_unless(sdf_kind(d_1_c_0_e_0) == S_BINARY);
fail_unless(sdf_subkind(d_1_c_0_e_0) == S_BINARY_EXPR_LOGEQ);
Expand Down

0 comments on commit c3dc17a

Please sign in to comment.