Skip to content

pavanpodila/clause-builder

Repository files navigation

Clause Parser

A clause is some text interspersed with placeholders. _placeholders, which will get their values when the clause is created.

Tags are specified with the following syntax:

[<name>: <source> { <field-path> <operator> <value> }]

The complete grammar can be found in grammar.pegjs

Quick Sample

Here's a sample clause with placeholders:

The weather at
    [city: city{name = "Bengaluru", country.name = "India"}] is
    [temp: city{temperature > 0}]°[unit: temperatureUnit{unit != ""}]

How's it built?

  • PegJS for parsing
  • MobX, React and Styled-Components for the demo

Demo

View the demo