Skip to content

Commit

Permalink
docs(quick-start): add quick start
Browse files Browse the repository at this point in the history
  • Loading branch information
Bikossor committed Aug 14, 2022
1 parent 534a555 commit 1c66b33
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions website/docs/getting-started/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Quick Start

After you have installed `Rudus` you can now create a new TypeScript _(or JavaScript)_ file inside your repo, call it `parser.ts` for example and copy the example below into it:

```ts
import { string, sequenceOf, whitespace } from "rudus";

const parser = sequenceOf([string("Hello"), whitespace(), string("World")]);

const parserResult = parser.run("Hello World");

console.log(parserResult);
```

And then run that file via [`ts-node`](https://typestrong.org/ts-node/):

```bash
npx ts-node parser.ts
```

In your console you should see an output like this:

```json
{
"input": "Hello World",
"isError": false,
"offset": 11,
"result": ["Hello", " ", "World"]
}
```

Congratulations! You have just made and run your first parser which is able to parse the string `"Hello World"` with `Rudus`.

0 comments on commit 1c66b33

Please sign in to comment.