npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@veridtools/feel-parser

v0.2.1

Published

FEEL expression lexer and parser — produces a typed AST from FEEL source

Readme

@veridtools/feel-parser

npm license ci docs dependencies

FEEL expression lexer and parser — produces a typed AST from FEEL source, zero dependencies.

@veridtools/feel-parser tokenizes and parses FEEL (Friendly Enough Expression Language) expressions as defined in the OMG DMN 1.5 specification. It produces a fully typed AST — evaluation is handled separately by @veridtools/feel-runner.

Install

pnpm add @veridtools/feel-parser
# or
npm install @veridtools/feel-parser

Quick start

import { parse, tokenize } from '@veridtools/feel-parser'

// Parse a FEEL expression into an AST
const ast = parse('price * quantity + discount')
// → BinaryOp { op: '+', left: BinaryOp { op: '*', ... }, right: Identifier { name: 'discount' } }

// Parse a unary test list (DMN input cell)
const tests = parse('[18..65], > 70', 'unary-tests')

// Multi-word names: pass known names so the parser resolves ambiguity
const ast2 = parse('order line item * 2', 'expression', new Set(['order line item']))

// Tokenize only
const tokens = tokenize('1 + 2 * 3')

CLI

Installed

# Install globally
pnpm add -g @veridtools/feel-parser
# or without installing
pnpx @veridtools/feel-parser "1 + 2"

# Parse an expression → AST JSON
feel-parser "if score >= 700 then \"approved\" else \"declined\""

# Multi-word known names
feel-parser "Monthly Salary * 12" --known-names "Monthly Salary"

# Unary-tests dialect (DMN input cell)
feel-parser "> 100, <= 200" --dialect unary-tests

# Token stream instead of AST
feel-parser "date and time(\"2024-01-15T10:30:00\")" --tokens

# Read expression from stdin
echo "for x in 1..5 return x * x" | feel-parser -

feel-parser --help

Try it locally (from the repo)

git clone https://github.com/veridtools/feel-parser
cd feel-parser
pnpm install

# Run without building (via tsx)
npx tsx bin/feel-parser.ts "1 + 2"
npx tsx bin/feel-parser.ts "format number(1234.56, \"#,##0.00\")"
npx tsx bin/feel-parser.ts "Monthly Salary * 12" --known-names "Monthly Salary"
npx tsx bin/feel-parser.ts "> 100, <= 200" --dialect unary-tests
npx tsx bin/feel-parser.ts "date(2024, 1, 1)" --tokens
npx tsx bin/feel-parser.ts --help

# Or build first and run the output directly
pnpm build
node dist/bin/feel-parser.js "some x in [1,2,3] satisfies x > 2"

API

parse(source, dialect?, knownNames?)

| Param | Type | Default | Description | |---|---|---|---| | source | string | — | FEEL expression source text | | dialect | FeelDialect | 'expression' | 'expression' or 'unary-tests' | | knownNames | Set<string> | new Set() | Multi-word names in scope |

Returns an AstNode. Throws a ParseSyntaxError with message, start, and end on parse failure.

tokenize(source)

Returns Token[]. Each token has type: TokenType, value: string, start: number, end: number.

safeParse(source, dialect?, knownNames?)

Like parse() but never throws. Returns { ast: AstNode, errors: ParseSyntaxError[] }.

On error, ast is a partial tree where invalid positions are filled with ErrorNode sentinels — the parser recovers and continues past each error.

const { ast, errors } = safeParse('1 +')
// ast    → BinaryOp { op: '+', left: NumberLiteral{1}, right: ErrorNode }
// errors → [ParseSyntaxError { message: '...', start: 3, end: 3 }]

const ok = safeParse('1 + 2')
// ok.ast    → BinaryOp { op: '+', ... }
// ok.errors → []

walk(node, visitor)

Depth-first traversal. Visitor is a partial record keyed by node type.

import { parse, walk } from '@veridtools/feel-parser'

const ast = parse('1 + 2 * 3')
const nums: string[] = []
walk(ast, { NumberLiteral: (n) => nums.push(n.value) })
// nums → ['1', '2', '3']

KNOWN_NAMES

Set<string> of all multi-word builtin names the parser recognises.

import { KNOWN_NAMES } from '@veridtools/feel-parser'
KNOWN_NAMES.has('date and time') // true

Source locations (loc)

Every AST node carries loc: { start: number; end: number } with byte offsets.

parse('"hello"').loc // { start: 0, end: 7 }

Types

import type { AstNode, ErrorNode, Token, FeelDialect, FeelType, RangeLiteral } from '@veridtools/feel-parser'
import type { Loc, ParseResult, Visitor } from '@veridtools/feel-parser'
import { ParseSyntaxError, TokenType, KNOWN_NAMES } from '@veridtools/feel-parser'

Development

pnpm install          # Install dependencies
pnpm build            # Build library + CLI (ESM + CJS)
pnpm test             # Run all tests
pnpm test:watch       # Watch mode
pnpm typecheck        # TypeScript type checking
pnpm check            # Lint + format (Biome)
pnpm docs:dev         # VitePress dev server
pnpm docs:build       # Build docs

Tests

All tests are colocated with the source files they cover (src/**/*.test.ts):

| File | Coverage | |---|---| | src/lexer/index.test.ts | Tokenizer — all token types, positions | | src/parser/index.test.ts | AST shapes for all node types | | src/parser/errors.test.ts | Parse errors and error messages | | src/parser/safeParse.test.ts | safeParse() contract — valid/invalid inputs, error shape, never throws | | src/parser/recovery.test.ts | Error recovery — ErrorNode, ParseSyntaxError, per-construct recovery, accumulation | | src/index.test.ts | Public API, DMN / TCK expression patterns | | src/language.test.ts | Full FEEL language coverage — all 80+ builtins, OMG DMN 1.5 conformance, vendor extensions | | src/summarize.test.ts | summarize() — header fields, root detail, node-type breakdown, loc spans |

Contributing

See CONTRIBUTING.md.

License

MIT — LICENSE