Skip to main content

Posts

Showing posts from March, 2019
We will begin by defining the grammar in pegjs.  PEG.js  is a parser generator for javascript. Our expression will be a boolean expression. It can have function calls. Lets assume this expression works on a javascript object. context = { name: 'sam', address: { addressLine: '2400 Dallas Pkwy', apartment: '356', state: 'TX' }, projects: [ { projName: 'pegjs parser', year: 2019 }, { projName: 'pratt parser', year: 2019 }, { projName: 'MyIMX233 PCB', year: 2017 } ], blogs: [ { title: 'naive react', year: 2019 }, { title: 'naive redux', year: 2018 } ] } Lets target these rules These rules take the context and can evaluate to some boolean result. These are mostly like filters, we can call these kinds of expressions as predicates. Then these predicates can be grouped into parenthesis. Also there can be functions calls which...