Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clitetailor/cursornext
A minimalist library for parsing :cactus:
https://github.com/clitetailor/cursornext
Last synced: 8 days ago
JSON representation
A minimalist library for parsing :cactus:
- Host: GitHub
- URL: https://github.com/clitetailor/cursornext
- Owner: clitetailor
- License: mit
- Created: 2019-09-08T06:41:30.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-16T21:22:00.000Z (about 1 year ago)
- Last Synced: 2024-12-01T19:47:50.550Z (22 days ago)
- Language: TypeScript
- Homepage:
- Size: 914 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
cursor|next
A minimalist parsing library for Node.js
## Why cursor|next?
While such frameworks like nearley, ohm and peg are powerful already and provide out-of-the-box features for generating and testing parser. These frameworks rely heavily upon LL and LR algorithms and grammars.
cursornext takes another approach, it provides the lowest lever interface to interact with the document and let you decide how to parse your own syntax. The downside is that you have to put more efforts building your own parser. Because you are not rely on any built-in algorithm and grammar, it may lacks of tools for checking and generating syntax tree. The upside is that building a parser tool is now more modular and customizable. The interface is also simple that it is much more friendlier to work with Chrome or Node debugger.
## Install
cursornext is available to install via npm:
```bash
npm install --save cursornext
```and Yarn:
```
yarn add cursornext
```### Create your first cursor
To create a new cursor, you can use `Cursor.from()` method:
```js
const { Cursor } = require('cursornext')const cursor = Cursor.from('Hello, World!')
```Now you can move and test the cursor using `next()` and `startsWith()`.
```ts
cursor.next(7)
cursor.startsWith('World')
// => true
```## Documentation
For more documentation, please checkout the [`docs`](./docs) directory:
- [Parsing Patterns](./docs/01-parsing-patterns.md)
- [Writing Tests](./docs/02-writing-tests.md)
- [Loc](./docs/03-loc.md)## License
[MIT License](LICENSE)