Skip to content

Add Ghost Dot Syntax#142

Open
rcosta358 wants to merge 1 commit intomainfrom
ghost-dot-syntax
Open

Add Ghost Dot Syntax#142
rcosta358 wants to merge 1 commit intomainfrom
ghost-dot-syntax

Conversation

@rcosta358
Copy link
Collaborator

This PR adds support for dot syntax in ghosts and states while keeping it backward compatible with the previous syntax. For this, a new non-terminal dotCall was added to the grammar and implemented in the AST visitor.

Currently, all of these equivalent: size(this), this.size(), and size(). To refer to the previous value of size, we can either use size(old(this)) or old(this).size.

In the future, we plan to drop the functional syntax and only keep the dot syntax to avoid ambiguity and confusion.

Example

@Ghost("int n")
public class CorrectDotNotationIncrementOnce {

    // explicit this
    @StateRefinement(to="this.n() == 0")
    public CorrectDotNotationIncrementOnce() {}

    // implicit this
    @StateRefinement(from="n() == 0", to="n() == old(this).n() + 1")
    public void incrementOnce() {}
}

@rcosta358 rcosta358 self-assigned this Feb 6, 2026
@rcosta358 rcosta358 added the enhancement New feature or request label Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant