processVars handles a cell fragment variable when it appears solely in a normal term, e.g,
rule run => foo(X) ...
X:XCellFragment
_
but not when it appears with other cells, e.g.,
rule run => foo(X C) ...
X:XCellFragment
C
resolveIncompleteCellFragment handles such cases, after processVars is done.
An idea is to fix invalid cell fragment terms. For example, processVars translates the term `foo(X)` into:
foo(-fragment A B -fragment C)
then resolveIncompleteCellFragment fixes the term as:
foo(-fragment A B C -fragment)
Another example:
When a cell fragment term consists of only individual cells, processVars does nothing.
rule run => foo(B C) ...
_
B:BCell
C:CCell
In this case, resolveIncompleteCellFragment fixes the term `foo(B C)` into:
foo(-fragment noACell B C -fragment)
Another example:
When a cell fragment variable appears only in a normal term, but never in cells, processVars does nothing.
rule foo(
_ X:XCellFragment) => bar(
2 X)
In this case, the cell fragment term in LHS is temporarily decorated by dummy cell label, before processVars,
which triggers processVars to split the cell fragment variable. Then resolveIncompleteCellFragment comes in.
After resolveIncompleteCellFragment, the dummy cell label is replaced by the corresponding cell fragment label.
The pre-/post-processing is done by preprocess/prostprocess.
Potential issue:
In the above example, if X has no sort casting, it is considered as XCellFragment by default,
which may be different with an user's intention.
Another potential issue:
Currently, one cannot represent a fully filled cell fragment term. e.g.,
rule foo(X) => .K ...
_ => X
The above rule replaces the entire cell with the cell fragment term X, but doesn't have a side condition
saying that X should be fully decorated. It means that X is given by a partially decorated cell fragment,
cell becomes invalid. e.g.,
foo(-fragment
1 noBCell noCCell -fragment)
results in an invalid cell:
1 noBCell noCCell
Note that this issue is not specifically about resolveIncompleteCellFragment.