https://github.com/typefox/langium-in-browser-codegen-example
Demonstrator of a fully-in-browser language implementation including code generation based on the arithmetics example language
https://github.com/typefox/langium-in-browser-codegen-example
Last synced: 10 months ago
JSON representation
Demonstrator of a fully-in-browser language implementation including code generation based on the arithmetics example language
- Host: GitHub
- URL: https://github.com/typefox/langium-in-browser-codegen-example
- Owner: TypeFox
- License: mit
- Created: 2023-01-18T17:16:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-03T12:34:17.000Z (over 2 years ago)
- Last Synced: 2025-06-08T00:11:25.234Z (10 months ago)
- Language: TypeScript
- Size: 83 KB
- Stars: 8
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**Update:** The implementation has been updated to Langium v2.0, and with that the branches *expandToString*, *expandToNode*, *expandTracedToNode*, and *main* have been force-pushed. The former commits are still available via the tags *expandToString-Langium-v1*, *expandToNode-Langium-v1*, and *expandTracedToNode-Langium-v1*. (October 25th, 2023)
Example application demonstrating a fully-in-browser DSL implementation including Code Generation based on Langium's arithmetics example DSL
[](https://github.com/langium/langium-in-browser-codegen-example/actions/workflows/actions.yml)
[](https://gitpod.io/#https://github.com/langium/langium-in-browser-codegen-example/)
This example project demonstrates the usage of Langium in the browser without any backend.
The language server is run in a web worker. It parses and validates the input text on change and — in this special case — sends a serialized snapshot of the abstract syntax tree (AST) to the browser's main thread, provided the text is free of errors. The code generation is than executed in the browser's main thread, and the obtained code is executed subsequently.
_Remark_: This setup well-suited for the sake of this demostration, but it is not common in production (yet 😁).
## Get started
Run
```
npm i
npm run serve
```
and open http://localhost:3000 in your browser.
Open the browser's developer tools, and put a break point at https://github.com/langium/langium-in-browser-codegen-example/blob/a2e590d9aeccf94178ebed83ab64ad40ebe1c635/src/arithmeticsEditor/index.ts#L44