문제

I have the following Alloy model and I'm not sure how to convert it to the Alloy Java API.

sig A {
  B: Int
}

I know we can use A.addField("B", Expr) to add the attribute, but what should I put in the Expr parameter to make it represents Ints?

Thanks

도움이 되었습니까?

해결책

It is much easier to parse the entire Alloy model from string instead of creating AST manually. See this post for an example. That example uses

CompUtil.parseEverything_fromFile(..., <file_name>)

but you can replace that with

CompUtil.parseOneModule_fromString("sig A{ B: Int}")

to parse directly from string (note that the return type in the latter case is List<Command>, and not CompModule like in the linked example, but that shouldn't be a problem for you).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top