Skip to content

Commit

Permalink
~forgot to update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AjaniBilby committed Feb 20, 2024
1 parent eeeb272 commit c71f92c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ chunk ::= "a"+ "b"+ ;
import * as syntax from "./bnf/example.js";

const tree /*(1)!*/ = syntax.Parse_Program("abbaabab").root;
const block /*(2)!*/ = program.value[0];
const chunk /*(2)!*/ = program.value[0];
const firstBs = program.value[1];
const bCount: number = firstBs.value.length; // (3)!
```
Expand Down
13 changes: 7 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ Compile your bnfs down to WebAssembly for maximum parsing speed; with generated


```bnf
program ::= %w* statement+ ;
block ::= %("block" w+) ...name %(w* "{" w*) seq_stmt* %("}" w*) ;
program ::= chunk+ ;
chunk ::= "a"+ "b"+ ;
```
```bash
npx bnf-compile ./syntax.bnf
```
```ts
import * as syntax from "syntax.js";
import * as syntax from "./bnf/syntax.js";

const tree = syntax.Parse_Program(input).root;
const block = program.value[0];
const name: string = block.value[0]; // typescript knows this **will** be a string
const tree /*(1)!*/ = syntax.Parse_Program("abbaabab").root;
const block /*(2)!*/ = program.value[0];
const firstBs = program.value[1];
const bCount: number = firstBs.value.length; // typescript knows this **will** be a number
```

**Built to be a devDependency** - if you use the included cli tool to generate your syntax parser you don't need to include this library as your dependency, you can just import those artifacts.
Expand Down

0 comments on commit c71f92c

Please sign in to comment.