我正在使用 VS Code 和 vscode-tlaplus 插件而不是 TLA+ Toolbox 来学习 TLA+。现在我有了这个 TLA 文件,我在其中定义了一些常量:
---- MODULE test ----
EXTENDS TLC, Integers, Sequences
CONSTANTS Capacity, Items, ValueRange, SizeRange
ItemParams == [size: SizeRange, value: ValueRange]
ItemSets == [Items -> ItemParams]
===
我想在 cfg 文件中设置以下内容:
SPECIFICATION Spec
CONSTANTS
SizeRange = 1..4
ValueRange = 0..3
Capacity = 7
Items = {"a", "b", "c"}
但这会导致以下错误:
TLC threw an unexpected exception.
This was probably caused by an error in the spec or model.
See the User Output or TLC Console for clues to what happened.
The exception was a tlc2.tool.ConfigFileException
:
TLC found an error in the configuration file at line 5
It was expecting = or <-, but did not find it.
到目前为止,我只找到了这个解决方法:
.tla
---- MODULE test ----
EXTENDS TLC, Integers, Sequences
CONSTANTS Capacity, Items, ValueRange, SizeRange
ConstSizeRange == 1..4
ConstValueRange == 0..3
ItemParams == [size: SizeRange, value: ValueRange]
ItemSets == [Items -> ItemParams]
====
.cfg
SPECIFICATION Spec
CONSTANTS
SizeRange <- ConstSizeRange
ValueRange <- ConstValueRange
Capacity = 7
Items = {"a", "b", "c"}
所以,定义一个 CONSTANT 似乎没用。
我做错了什么,或者这是预期的行为?
谢谢