好吧,我可以看到的一个问题是,您的规则中有<k>
和<T>
单元格彼此相邻,但在初始配置中它们没有兄弟关系。
SIMPLE 配置如下所示,其中<k>
单元格是单元格的孙子<T>
:
configuration <T color="red">
<threads color="orange">
<thread multiplicity="*" color="yellow">
<k color="green"> $PGM:Stmts ~> execute </k>
<control color="cyan">
<fstack color="blue"> .List </fstack>
<xstack color="purple"> .List </xstack>
</control>
<env color="violet"> .Map </env>
<holds color="black"> .Map </holds>
<id color="pink"> 0 </id>
</thread>
</threads>
<genv color="pink"> .Map </genv>
<store color="white"> .Map </store>
<busy color="cyan"> .Set </busy>
<terminated color="red"> .Set </terminated>
<input color="magenta" stream="stdin"> .List </input>
<output color="brown" stream="stdout"> .List </output>
<nextLoc color="gray"> 0 </nextLoc>
</T>
所以如果你想写你的规则,你至少必须这样做:
syntax Stmt ::= "printConfig" ";"
rule <T> ... <k> printConfig; => print(CFG); ... </k> ... </T> #as CFG
请注意,我在这里做了三处更改,(1)我对变量 CFG 使用了大写字母(在 K 中是常规的),(2)我在单元格...
的末尾添加了程序结束,以及 (3) 我使用模式同时匹配超项和子项,为超项命名。<k>
printConfig;
_#as_
<T> ... </T>
<k> ... </k>
CFG
_#as_
模式记录在Pending Documentation中。
希望有帮助!