-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |