Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose operators and precedences #67

Open
LeaVerou opened this issue Sep 18, 2017 · 0 comments
Open

Expose operators and precedences #67

LeaVerou opened this issue Sep 18, 2017 · 0 comments

Comments

@LeaVerou
Copy link
Collaborator

There are many use cases where you want to inspect which operators are currently registered and/or look up their precedences.

E.g. Assume you want to add and as a synonym for &&. Currently one has to look at the code to find the precedence of && and use the same. And of course, that means it cannot be done dynamically, on runtime.
Or you may just need to look up whether an operator is registered. Currently the only way to do that is to try and parse a test expression.

This could be done in a number of ways:

  1. Just expose unary_ops and binary_ops on jsep.
  2. Add functions that accept an operator and return its precedence (we already have that for binary operators in binaryPrecedence(), we just need to expose it.

@EricSmekens Once I know how you'd rather proceed, I can implement it and send a PR.

And while we're at it, we could also expose isDecimalDigit, isIdentifierStart etc so they can be overridden, to create an even more extensible parser 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant