0.2.0 • Published 4 years ago

@mockpiler/lexer v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@mockpiler/lexer

Lexical Analyzer for MockpilerJS

Usage

import { Lexer } from '@mockpiler/lexer'

const input = `
  [
    (2) {
      name
      age
    }
  ]
`

const lexer = new Lexer(input)
const tokens = lexer.scan()

console.log(tokens)

/**
 * Output:
 *
 *  [
 *    {
 *      type: 'array',
 *      value: '[',
 *      location: {
 *        start: {
 *          line: 2,
 *          column: 3
 *        },
 *        end: ...
 *      }
 *    },
 *    ...
 *  ]
 */