单个可选赋值的布尔字段和值赋值(boolean field and value assignment for single optional assignment)

有一种简单的方法可以在最终模型中为可选属性和值赋值设置一个布尔字段吗? 例如这样:

Enum: name=ID assigned=( '(' value=INT ')' )? ;

我的目标是使用类似于C的枚举类型,如果没有明确指定枚举值,它将从0或最后指定的值开始计数。

我想我需要在后面的步骤中计算最终值,但在那里我需要用户给出哪些值的信息。

也许甚至有一个更简单的解决方案......

Is there an easy way to have a in the final model a boolean field for a optional attribute AND a value assignment? For example like this:

Enum: name=ID assigned=( '(' value=INT ')' )? ;

My goal is to have an enum type similar to C where if you do not specify the enum value explicitly it will count from 0 or the last specified value.

I guess I need to compute the final values in a later step, but there I would need the information which of the values were given by the user.

Maybe there is even an easier solution to this...

最满意答案

看看?=运算符

Enum: name=ID (assigned?='(' value=INT ')')?;

Have a look at the ?= operator

Enum: name=ID (assigned?='(' value=INT ')')?;单个可选赋值的布尔字段和值赋值(boolean field and value assignment for single optional assignment)

有一种简单的方法可以在最终模型中为可选属性和值赋值设置一个布尔字段吗? 例如这样:

Enum: name=ID assigned=( '(' value=INT ')' )? ;

我的目标是使用类似于C的枚举类型,如果没有明确指定枚举值,它将从0或最后指定的值开始计数。

我想我需要在后面的步骤中计算最终值,但在那里我需要用户给出哪些值的信息。

也许甚至有一个更简单的解决方案......

Is there an easy way to have a in the final model a boolean field for a optional attribute AND a value assignment? For example like this:

Enum: name=ID assigned=( '(' value=INT ')' )? ;

My goal is to have an enum type similar to C where if you do not specify the enum value explicitly it will count from 0 or the last specified value.

I guess I need to compute the final values in a later step, but there I would need the information which of the values were given by the user.

Maybe there is even an easier solution to this...

最满意答案

看看?=运算符

Enum: name=ID (assigned?='(' value=INT ')')?;

Have a look at the ?= operator

Enum: name=ID (assigned?='(' value=INT ')')?;