Demo
gnip-rule-parser
Parse GNIP PowerTrack/Search rules into an abstract syntax tree.
If you want to validate rules, I strongly suggest you use the validation API endpoint.
Getting Started
Installation
npm install --save gnip-rule-parser
Running The Tests
mocha
Usage
var parser = require( 'gnip-rule-parser' );
try
{
var ast = parser.parse( 'happy OR party' );
console.log( ast );
}
catch( err )
{
// Rule isn't valid
}
Output
[
{
name: 'boolean',
value: 'OR',
leftBranch:
{
name: 'keyword',
value: 'happy'
},
rightBranch:
{
name: 'keyword',
value: 'party'
}
}
]
License
MIT