Multiple cross references with different options [message #1481040] |
Thu, 20 November 2014 18:06 |
Lynn Lu Messages: 3 Registered: November 2014 |
Junior Member |
|
|
Hi,
I met a problem when using cross reference, here is the my rule definitions:
Model:
Struct | Enum
;
Enum:
'enum' name = ID '{'
fields += EnumField*
'}' ';'
;
EnumField:
name = ID ';'
;
Struct:
'struct' name = ID '{'
fields += StructField*
'}' ';'
;
StructField:
ref = [Struct] name = ID opt = StructFieldOpt? ';'
| ref = [Enum] name = ID opt = EnumFieldOpt? ';'
;
StructFieldOpt:
',' 'fixed'
;
EnumFieldOpt:
',' 'default' '=' value = INT
;
My goal is to support the following model. i.e. there are different options available for different cross reference.
enum myEnum {
enumField1;
enumField2;
}
struct myStruct1 {
};
struct myStruct2 {
myEnum theFirstEnum, default = 1;
myStruct1 theFirstStruct, fixed;
};
But the above syntax will not work, because the StructField rule is not valid, it has conflict between these two alternatives.
I can change the StructField as below, 'Model' is the superset of target referenced rule "Struct" and "Enum"
StructField:
ref = [Model] name = ID ....
;
But how can I define my options? can someone help? Thank you
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03354 seconds