Skip to content

SMV: complex identifiers are now parsed as expressions #1195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2025

Conversation

kroening
Copy link
Member

NuSMV allows a subset of the expression syntax to be used as variable identifiers. This changes the SMV grammar to use expressions to store the result of the complex_identifier rule.

NuSMV allows a subset of the expression syntax to be used as variable
identifiers.  This changes the SMV grammar to use expressions to store the
result of the complex_identifier rule.
@kroening kroening added the SMV label Jul 11, 2025
@kroening kroening marked this pull request as ready for review July 11, 2025 17:58
else if(expr.id() == ID_member)
{
auto &member_expr = to_member_expr(expr);
return id2string(merge_complex_identifier(member_expr.compound())) + '.' + id2string(member_expr.get_component_name());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In CBMC's field sensitivity encoding we chose .. as separator to avoid confusing humans as to whether they see an identifier or an expression. Would that also be a possible concern (and solution) here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did worry about this, but SMV doesn't have a struct type.

auto &index = index_expr.index();
PRECONDITION(index.is_constant());
auto index_string = id2string(to_constant_expr(index).get_value());
return id2string(merge_complex_identifier(index_expr.array())) + '.' + index_string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In keeping with the above comment: would "[[" + index_string + "]]" be a more human-friendly choice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SMV does have an array type, and confusingly, uses the same syntax for those identifiers and arrays. Using say [[ would make the difference clear, but then be incompatible with NuSMV.

@kroening kroening merged commit 6feb680 into main Jul 11, 2025
10 checks passed
@kroening kroening deleted the smvlang-complex-identifier branch July 11, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants