# simplelexer

> A simple (linear) lexer for converting a language string into a sequence of user-defined TOKEN_TYPES.

Latest version **1.0.8** (published 2021-10-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install simplelexer
pnpm add simplelexer
yarn add simplelexer
bun add simplelexer
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2021-10-12 |
| First published | 2021-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Inventor Dave |
| Maintainers | leedavidodea |
| Keywords | lexer, parser, tokenizer, javascript |

## Links

- npm: https://www.npmjs.com/package/simplelexer
- Repository: https://github.com/InventorDave/SimpleLexer
- Homepage: https://github.com/InventorDave/SimpleLexer#readme
- Issues: https://github.com/InventorDave/SimpleLexer/issues
- npm.io page: https://npm.io/package/simplelexer

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2021-10-12
- 1.0.3 — 2021-09-28
- 1.0.2 — 2021-09-28
- 1.0.1 — 2021-09-28
- 1.0.0 — 2021-09-28

## README

# SimpleLexer
A simple lexer.
 
 Usage:
 
The Lexer is in an mjs file (it's in ES6 syntax, and module format). See main.js in the package for a quick way to test the Lexer.

node main.js

As you can see, once the import() Promise has returned, you simply do the following:
 
let lexer = new Lexer('Assuming you install suitable Lex patterns, this string will be successfully tokenized!', installLexRules)
let stack = lexer.lex()
 
Results are also stored in Lexer.Stack (Using above example method, you would peek at 'stack', but you can also peek at 'lexer.Stack'.)
 
There is a sample lex file called "js.txt" with the package, but it's lex rules are generic enough for the majority of programming language strings, and English-language strings, too.


 
 Input lex file format:
 
 1 pattern & token string per line, as so:
 
 [0-9]+                      $$ "NUM"
 
 The seperator between the pattern and the token string is $$
 
 InventorDave.

---
_Source: https://npm.io/package/simplelexer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
