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

[Proposal] MathExpressionConverter boolean support #2181

Open
CliffAgius opened this issue Sep 5, 2024 Discussed in #2084 · 0 comments
Open

[Proposal] MathExpressionConverter boolean support #2181

CliffAgius opened this issue Sep 5, 2024 Discussed in #2084 · 0 comments
Labels
proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail

Comments

@CliffAgius
Copy link
Contributor

Discussed in #2084

Originally posted by stephenquan August 1, 2024
This is a Math Expression Converters #71 refactor enhancement to improve the parser by (1) using a Parsing expression grammar, and (2) to support boolean operations. The grammar is now:

Expr        ::= Conditional
Conditional ::= LogicalOr ( '?' LogicalOr ':' LogicalOr ) ?
LogicalOr   ::= LogicalAnd ( '||' LogicalAnd ) *
LogicalAnd  ::= Equality ( '&&' Equality ) *
Equality    ::= Compare ( ( '==' | '!=' ) Compare ) *
Compare     ::= Sum ( ( '>=' | '>' | '<=' | '<' ) Sum ) *
Sum         ::= Product ( ( '+' | '-' ) Product ) *
Product     ::= Power ( ( '*' | '/' ) Power ) *
Power       ::= Primary ( '^' Primary ) *
Primary     ::= Number
              | Function
              | Constant
              | '(' Expr ')'
              | ( '-' | '!' ) Primary
Number      ::= ( '-' ) ? ( ( [0-9]+ '.' [0-9]+ ) | [0-9]+ )
Function    ::= [a-z]+ ( '(' ')' | '(' Expr ( ',' Expr ) * ')' )
Constant    ::= [a-z]+

Where Conditional, LogicalOr, LogicalAnd, Equality, and Compare are new. true and false boolean constants are also new. Sum, Product, Power, Primary, Number, Function, and Constant are a refactor of what was already supported by the original parser.

The implementation can be found:

References:

@CliffAgius CliffAgius added approved This Proposal has been approved and is ready to be added to the Toolkit proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail and removed approved This Proposal has been approved and is ready to be added to the Toolkit labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail
Projects
None yet
Development

No branches or pull requests

1 participant