1.3.4 • Published 5 months ago

formula-cli v1.3.4

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Formula

Simple language for describing data formats, transpilable to RegExp.

Syntax

Example of advanced formula:

# Variables
define VAL match '[a-f0-9]'
define VAL_3 match(3) VAL
define VAL_6 match(6) VAL

# Tests
test '#fff'
test '#ababab'
test '#000000'
test '#f0f0f0'

# Formula
match START
match '#'
group {
	match VAL_3 | VAL_6 # 3 or 6 hex values
}
match END

Formula is gonna be transpiled into following RegExp:

^#((?:[a-f0-9]{3})|(?:[a-f0-9]{6}))$

Usage

Install a Formula CLI globally:

npm i formula-cli -g

After installation you can use CLI to compile formula file:

formula compile example.formula

And also you can compile the whole directory:

formula compile src --dir

For running a tests inside formula:

formula test example.formula

Examples

You can see examples of formulas in /example directory in this repository.

Changelog

v1.2.2

  • Added lookahead & lookbehind syntax (match ...'a' | 'a'...)

v1.2.1

  • Fixed infinite loop when # at the end of file

v1.2.0

  • Added testing system that allows to test formulas matching
  • Added formula test CLI command
  • Added test

v1.1.1

  • Added support of both string formats (' and ")
  • Added support of +/(min,max) and ? to groups
  • Added | operator for matching
  • Fixed if-else compilation

v1.1.0

  • Added formula compile CLI command
  • Added match
  • Added group
  • Added if and else
  • Added define
1.3.4

5 months ago

1.3.3

5 months ago

1.2.0

8 months ago

1.2.2

8 months ago

1.2.1

8 months ago

1.1.1

12 months ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago