gnebehay / parser

A simple parser for mathematical expressions.
MIT License
169 stars 17 forks source link

I ported the parser to TypeScript and used it as a permission DSL #8

Closed nicolaes closed 3 years ago

nicolaes commented 3 years ago

If you think it's useful, I can make it into a PR. https://stackblitz.com/edit/typescript-vhd3tn?file=index.ts

gnebehay commented 3 years ago

This is very cool! I'll add a link to the Readme!

theRealProHacker commented 1 year ago

For me at least, it is not very clear what a permission DSL is. Searching did not help. Maybe it would be helpful to explain what that means and how it is related to a parser for mathematical expressions.

nicolaes commented 1 year ago

Hi @theRealProHacker,

Sorry I'm just now seeing your comment. My code uses the parser to combine permissions. By permission DSL I understand an AND-OR language that you apply for permissions. Basically a boolean logic parser. E.g. in Angular:

<div *appDisplayIf="isPremiumUser AND (subscribed OR hasTrial)">
   Premium content.
</div>

This boolean logic DSL evolved quite nice since I started using it and is still the most condensed algorithm I found. It's used by non-technical people in my project to configure UI permissions and display conditions.

theRealProHacker commented 1 year ago

Ah, okay now I see. So you replace + and - with AND and OR?

But what does the abbreviation "DSL" even stand for? Is it "domain specific language"?

nicolaes commented 1 year ago

@theRealProHacker yes, + and - are replaced with AND / OR. It's a domain specific language because you can write rudimentary boolean logic with it.