https://github.com/nikku/lezer-feel
Lezer grammar definition for the DMN 1.3 FEEL language
https://github.com/nikku/lezer-feel
dmn dmn-feel feel lezer-grammar
Last synced: 4 months ago
JSON representation
Lezer grammar definition for the DMN 1.3 FEEL language
- Host: GitHub
- URL: https://github.com/nikku/lezer-feel
- Owner: nikku
- License: mit
- Created: 2020-04-11T19:36:44.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-01-12T19:36:16.000Z (over 1 year ago)
- Last Synced: 2025-03-27T11:50:30.432Z (about 1 year ago)
- Topics: dmn, dmn-feel, feel, lezer-grammar
- Language: JavaScript
- Homepage:
- Size: 671 KB
- Stars: 12
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lezer-feel
[](https://github.com/nikku/lezer-feel/actions/workflows/CI.yml)
This is a [DMN](https://www.omg.org/spec/DMN/) FEEL grammar for the
[Lezer](https://lezer.codemirror.net/) parser system.
## Usage
Parse FEEL to a [`Tree`](https://lezer.codemirror.net/docs/ref/#common.Tree):
```javascript
import {
parser
} from 'lezer-feel';
// parse
parser.parse('foo > 1');
```
#### Choose Dialect
Use `Expression` or `UnaryTests` as a [top node](https://lezer.codemirror.net/docs/ref/#lr.LRParser.topNode) depending on which FEEL dialect you intend to parse:
```javascript
import {
parser
} from 'lezer-feel';
const unaryParser = parser.configure({
top: 'UnaryTests'
})
// parse
unaryParser.parse('> 100');
```
#### Provide Context
Override the default [context tracker](https://lezer.codemirror.net/docs/ref/#lr.ParserConfig.contextTracker) to enable context sensitive parsing based on inputs:
```javascript
import {
parser,
trackVariables
} from 'lezer-feel';
const contextTracker = trackVariables({
'if foo then bar': 1
});
const contextualParser = parser.configure({
contextTracker
});
// recognizes as a
contextualParser.parse('if foo then bar');
```
## Development
```shell
# build and test
npm run all
# test
npm test
# test (debug)
LOG=fparse:dbg,fparse,context,parse npm test
```
Prefix [individual](./test/expressions.txt) [tests](./test/unary-tests.txt) with a `*` to test them in focus mode:
```markdown
# *ArithmeticExpression (error)
...
```
## Related
* [feelin](https://github.com/nikku/feelin) - Interpreter for the FEEL language
* [feel-playground](https://github.com/nikku/feel-playground) - A visual playground to learn the FEEL language
* [lang-feel](https://github.com/nikku/lang-feel) - Integration into a [CodeMirror](https://codemirror.net/) editor
## License
The code is licensed under an MIT license.