Support for Xtext enum #1475
|
We had a language in Xtext. We are migrating into Langium. Xtext had concept of enum values like this. I haven't seen any mention of this in Langium grammar.
|
Replies: 3 comments 4 replies
|
I'd recommend you read this article: https://www.typefox.io/blog/xtext-to-langium/ and this discussion: #521. But answering your question using the article approach, then it would be something like this: Xtext: Langium: type ForLiterals = 'update' | 'view' | 'reference';
ForLiterals returns ForLiterals:
ForLiterals_Update | ForLiterals_View | ForLiterals_Reference
;
ForLiterals_Update returns string: 'update';
ForLiterals_View returns string: 'view';
ForLiterals_Reference returns string: 'reference'; |
|
Thank you for that great reference. We could convert our old xtext based grammar into Langium. There were couple of issues. The ML and SL comments were not working when we migrated. We had to redo that part. Other than that we haven't seen other issues. Will keep an eye and post about any issues here. |
|
Hi, sorry to bother this old thread but I am trying to do something similar, without success. I have the following grammar: interface Root {
color: Color
}
type Color = 'red' | 'blue' | 'green';
entry RootRule returns Root:
'color' color=ColorRule
;
ColorRule returns Color:
'red'
| 'blue'
| 'green'
;And I get this error: What am I doing wrong? :( |

I'd recommend you read this article: https://www.typefox.io/blog/xtext-to-langium/ and this discussion: #521.
But answering your question using the article approach, then it would be something like this:
Xtext:
Langium: