Skip to content

Commit

Permalink
feat(lexer): updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
halvardssm committed Oct 15, 2024
1 parent a37ea01 commit 34aba72
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion lexer/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
# @stdext/lexer

The lexer package contains general purpose lexers/tokenizers
The lexer package contains general purpose lexers/tokenizers.

## Example

```ts
const t = new StringTokenizer({
data: "testa",
matchers: [
{
key: (v, i) => v === "t" && i === 3,
handler: (v, i) => ({
index: i,
type: "function",
value: v,
}),
},
{
key: "t",
handler: (v, i) => ([
{
index: i,
type: "string",
value: v,
},
2
]),
},
{
key: /[es]/,
handler: (v, i) => ({
index: i,
type: "regex",
value: v,
}),
},
],
defualtHandler:(v, i) => ({
index: i,
type: "default",
value: v,
}),
});
*
const tokens = t.tokenize();
```

0 comments on commit 34aba72

Please sign in to comment.