Skip to content
hyperjump-ioPublic

About

Compile ABNF grammars into regular expressions

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Hyperjump - ABNF

Compile grammars written in ABNF into regular expressions. ABNF is the notation that RFCs use for syntax, so you can paste an RFC's rules in and get a RegExp that matches what the RFC describes.

Read the documentation at hyperjump.io

npm install @hyperjump/abnf
import { abnf } from "@hyperjump/abnf";

const fullDate = abnf()`
  full-date     = date-fullyear "-" date-month "-" date-mday
  date-fullyear = 4DIGIT
  date-month    = 2DIGIT
  date-mday     = 2DIGIT
`;

fullDate.test("2004-01-15"); // true
  • RFC 5234 and RFC 7405. Rules, repetition, options, groups, numeric values, and case-insensitive and case-sensitive strings, with the core rules built in.
  • A regular expression. The result is a RegExp with the u flag, as fast as one written by hand.
  • What you know about the input. A context can supply rules to reference, characters that end a match, and characters the input can't have.
  • Small. No dependencies. TypeScript types included. Works in Node.js and browsers.

Documentation

Contributing

See design/ for how it works and why.

npm install
npm test
npm run lint
npm run type-check

License

MIT

About

Compile ABNF grammars into regular expressions

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages