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.
npm install --save gnip-rule-parser
mocha
var parser = require( 'gnip-rule-parser' );
try
{
var ast = parser.parse( 'happy OR party' );
console.log( ast );
}
catch( err )
{
// Rule isn't valid
}
[
{
name: 'boolean',
value: 'OR',
leftBranch:
{
name: 'keyword',
value: 'happy'
},
rightBranch:
{
name: 'keyword',
value: 'party'
}
}
]
MIT