I have two different grammars returning the same type. I want to differentiate the two grammars by enum.
Grammar1 returns Book:
'Type' classification=ID 'Author' name=ID 'Title' title=ID';'
;
Grammar2 returns Book:
'Reference' classification=ID 'Author' name=ID 'Publish' date=ID 'Title' title=ID ';'
;
My xcore model has a class Book.
class Book {
String classification
String name
String title
String date
}
This requires me to do a string compare for the classification variable. I want to differentiate Grammar1 with Grammar2 by using an enum.
enum eType :
fiction = 'FICTION' |
classic = 'CLASSIC' ;
Grammar1 returns Book:
'Type' classification=eType::FICTION 'Author' name=ID 'Title' title=ID';'
;
Grammar2 returns Book:
'Reference' classification=eType::CLASSIC 'Author' name=ID 'Publish' date=ID 'Title' title=ID ';'
;
How can I set the literal value of an enum to a variable? Do I need to create a value converter?