Skip to content

Commit b6093cc

Browse files
committed
vlindex: fix parsing for constraint_block
1 parent b97a3e7 commit b6093cc

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/vlindex/vlindex_parser.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -932,14 +932,31 @@ void verilog_indexer_parsert::rConstraint()
932932
next_token(); // static
933933
}
934934

935-
next_token(); // constraint
935+
auto constraint_token = next_token(); // constraint
936+
PRECONDITION(constraint_token == TOK_CONSTRAINT);
936937

937938
next_token(); // identifier
938939

939-
if(next_token() != '{') // onstraint_block
940-
return; // error
940+
// constraint_block
941+
auto first = next_token();
942+
if(first != '{')
943+
return; // error
944+
std::size_t count = 1;
941945

942-
skip_until('}');
946+
while(true)
947+
{
948+
auto token = next_token();
949+
if(token.is_eof())
950+
return;
951+
else if(token == '{')
952+
count++;
953+
else if(token == '}')
954+
{
955+
if(count == 1)
956+
return;
957+
count--;
958+
}
959+
}
943960
}
944961

945962
void verilog_indexer_parsert::rContinuousAssign()

0 commit comments

Comments
 (0)