Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.1 KB

.verb.md

File metadata and controls

38 lines (25 loc) · 1.1 KB

What is this?

This is a simple Lexical Scanner that takes an object of regex patterns, and uses those patterns to process an input string into an array of tokens.

What is the difference between this and [snapdragon-lexer][]?

snapdragon-lexer uses registered handler functions to capture and handle tokens, snapdragon-scanner simply iterates over an object of regular expression patterns to create tokens. You can think of snapdragon-scanner as the "lite" version of snapdragon-lexer.

Usage

const Scanner = require('{%= name %}');

API

{%= apidocs("index.js") %}

Token objects

Scanner tokens are plain JavaScript objects with the following properties:

{
  type: String;
  value: String
  match: Array
}

Token properties

  • type {String} - The name of the regex that matched the substring.
  • value {String} - The substring that was captured by the regex.
  • match {Array} - The match array from RegExp.exec()

Release history

See the changelog.