Giter Site home page Giter Site logo

selectively's Introduction

template-library

Template for NPM library.

Selectively Grammar

Symbols

  • bool-expr (boolean expression)
  • prop (property, identifier (id) or combination of identifiers, e.g. identifier.identifier (id.id))
  • id (identifier)
  • expr (expression)
  • expr-op (expression operator e.g. >, <, >=, <=)
  • alg-expr (algebraic expression)
  • bin-op (binary operator)

Production Rules

Boolean Rules:

  • bool-expr -> prop ":" expr | prop expr-op expr | (bool-expr) | bool-expr "|" bool-expr | bool-expr bool-expr | !bool-expr
  • prop -> prop "." id | id
  • expr -> prop | string | alg-expr | (expr) | "!"expr | expr "|" expr
  • expr-op -> < | > | <= | >=

Algebraic Rules:

  • alg-expr -> number | alg-expr bin-op alg-expr | (alg-expr)
  • bin-op -> + | - | / | *

Merchant Rules

All id could be id.id.id...

Allowed Strings

id>num  
id<=str  
!(id:str)  
id:(str | str)  
id:((str | str) | str)  
(id<num)  
id:num  
id:!num  
id:!(num | num)  
id:(num | !num)  
id:id  
id>id  
(((id>num)))  
(id>(num))  
id.id:(id.id | str | num) | id.id.id:id.id  
id>num + num  
id<= num + (num * num) / num - num

Disallowed Strings

Open brackets:

(((id>num))

Mix of prop ":" expr and prop expr-op expr

id:(id>num)   

Special Rules

prop expr-op expr

Left-hand side:

Can be ambiguous, e.g. amount, where amount is an identifier which can be found as a property on several properties.

Right-hand side:

Can't be ambiguous, it must refer to a string, number or a unique identifier, e.g. "uniqueIdentifier.amount". An ambiguous identifier will be interpreted as a string. 

What is What?

  • 3.14 => number
  • identifier | identifier.identifier => property or properties
  • unique_identifier.identifier => property
  • .identifier => property if the identifier is a property of the base object, otherwise string.
  • 1.B2 => string
  • card.3d.secure => property
  • 20-12-24 => string
  • 20 - 12 - 24 => algebraic expression (uses whitespaces around the operators.)
  • "20 - 12 - 24" => string. ("" forces an)
  • Violation of the rules gives red underlining.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.