[SOLVED] Serializer Enum [message #1411842] |
Sun, 24 August 2014 15:57 |
Jonas Heinisch Messages: 12 Registered: June 2014 Location: Germany |
Junior Member |
|
|
Hi!
I've got a problem regarding the usage of enums.
Here's a part of my used grammar:
// boolAndExpr -> boolOrExpr (andoperation boolOrExpr)*
boolAndExpr returns BooleanExpression:
boolOrExpr ({BooleanOperatorExpression.left=current} operation=andoperation right=boolOrExpr)*
;
// andoperation -> AND
enum andoperation returns BooleanOperations:
AND
;
// boolOrExpr -> compareExpr (oroperations compareExpr)*
boolOrExpr returns BooleanExpression:
compareExpr ({BooleanOperatorExpression.left=current} operation=oroperations right=compareExpr)*
;
// oroperations -> OR|XOR
enum oroperations returns BooleanOperations:
OR | XOR
;
Parsing works pretty good, but when it comes to serializing something containing an AND this Exception comes up:
The value 'AND' is invalid for enum oroperations
Valid values are: OR, XOR
Semantic Object: BooleanOperatorExpression
I think it could be easily changed by changing the model and split up AND- and OR-Operations into two classes. But as it is a running system to which I only add the Xtext-things, I do not want to change the model that much... So any idea how to solve this?
Thanks in advance for any hints!
Jonas
[Updated on: Sun, 24 August 2014 18:18] Report message to a moderator
|
|
|
|
|
|
Re: Serializer Enum [message #1411877 is a reply to message #1411870] |
Sun, 24 August 2014 18:18 |
Jonas Heinisch Messages: 12 Registered: June 2014 Location: Germany |
Junior Member |
|
|
Hi!
Thanks a lot!
This works great:
...
//BooleanExpression -> boolOrExpr (BooleanOperations boolOrExpr)*
// Note: This is a workaround for the serializer to work with AND-Operations!
BooleanExpression:
boolOrExpr ({BooleanOperatorExpression.left=current} operation=BooleanOperations right=boolOrExpr)*
;
//BooleanOperations -> AND | OR | XOR
enum BooleanOperations:
AND | OR | XOR
;
// boolAndExpr -> boolOrExpr (andoperation boolOrExpr)*
boolAndExpr returns BooleanExpression:
boolOrExpr ({BooleanOperatorExpression.left=current} operation=andoperation right=boolOrExpr)*
;
// andoperation -> AND
enum andoperation returns BooleanOperations:
AND
;
// boolOrExpr -> compareExpr (oroperations compareExpr)*
boolOrExpr returns BooleanExpression:
compareExpr ({BooleanOperatorExpression.left=current} operation=oroperations right=compareExpr)*
;
// oroperations -> OR|XOR
enum oroperations returns BooleanOperations:
OR | XOR
;
...
Best regards
Jonas
[Updated on: Sun, 24 August 2014 18:19] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04351 seconds