@adrianhelvik/syntax

## Installation

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@adrianhelvik/syntax
Minified + gzip package size for @adrianhelvik/syntax in KB

Readme

@adrianhelvik/syntax

Installation

npm i --save @adrianhelvik/syntax
yarn add @adrianhelvik/syntax

Usage

const syntax = {
  lex: [
    ['whitespace', /^\s+/, 'ignore'],
    ['keyword', /^(let)/],
    ['symbol', /^[()=]/],
    ['ident', /^[a-zA-Z][a-zA-Z0-9]*/],
    ['number', /^[0-9]+/],
  ],
  parse: {
    main: ['either', 'many', [
      'assignment',
      'funcCall',
      'varDecl',
    ]],
    funcCall: ['sequence', [
      'ident',
      'symbol:(',
      'symbol:)',
    ]],
    assignment: ['sequence', [
      'keyword:let',
      'symbol:=',
      'expression',
    ]],
    expression: ['either', [
      'number',
      'ident',
    ]]
  }
}
const source = `
let i = 0

while (i < 10)
  i = increment(i)

console.log(i)
`

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.