https://github.com/typefox/xtext2langium
A tool for migrating an Xtext language to Langium
https://github.com/typefox/xtext2langium
langium migration xtext
Last synced: 2 months ago
JSON representation
A tool for migrating an Xtext language to Langium
- Host: GitHub
- URL: https://github.com/typefox/xtext2langium
- Owner: TypeFox
- License: mit
- Created: 2022-10-27T14:52:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-02T15:24:53.000Z (over 2 years ago)
- Last Synced: 2025-06-28T06:36:27.328Z (9 months ago)
- Topics: langium, migration, xtext
- Language: Xtend
- Homepage: https://www.typefox.io/blog/xtext-to-langium
- Size: 823 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/TypeFox/xtext2langium/actions/workflows/main.yml)
# Convert Xtext to Langium
#### Generator Fragment for MWE2 Workflow
This MWE2 fragment reads your Xtext grammar and converts it to Langium.
If you are using a predefined Ecore model (not generated), it will also be converted to Langium as a type definition file.
#### How to consume
##### P2 Repository
Add the `https://typefox.github.io/xtext2langium/download/updates/v0.4.0/` update site to your `.target` file as an additional location.
```xml
```
##### Maven
```xml
io.typefox.xtext2langium
io.typefox.xtext2langium
0.4.0
```
##### Gradle
```
io.typefox.xtext2langium:io.typefox.xtext2langium:0.4.0
```
#### How to use
Add the fragment to you Language configuration in the MWE2 file and
configure the output path.
```js
language = StandardLanguage {
name = "io.typefox.Example"
// ... //
fragment = io.typefox.xtext2langium.Xtext2LangiumFragment {
outputPath = './langium'
}
```
After running the workflow you will find the generated Langium output in `./langium` folder.
##### Fragment options
- `outputPath` - Target output folder
- `prefixEnumLiterals` - If `true`, enum literal types will be prefixed with the enum type name to avoid name conflicts with other enum literals. Default is `true`. Example: `enum Color: RED;` will create: `Color returns Color: Color_RED; Color_RED returns string: 'RED';`
- `useStringAsEnumRuleType` - If `true`, Enum types will be handled as strings. Only relevant for generated metamodels. Default is `false`.
- `generateEcoreTypes` - If `true`, types from the Ecore metamodel will also be generated. If `false`, ecore data types will be replaced with Langium data types. Types that are not convertible to Langium built in types will be generated as string. Default is `false`.
- `removeOverridenRules` - In case a rule from the imported grammar was overwritten, Langium will report a duplicate error. If `true`, the super grammar rules will be skipped in favour of the current grammar rules. Default is `false`.