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.
cursornext is available to install via npm:
npm install --save cursornext
and Yarn:
yarn add cursornext
To create a new cursor, you can use Cursor.from()
method:
const { Cursor } = require('cursornext')
const cursor = Cursor.from('Hello, World!')
Now you can move and test the cursor using next()
and startsWith()
.
cursor.next(7)
cursor.startsWith('World')
// => true
For more documentation, please checkout the docs
directory: