Skip to content

[Proposal] MathExpressionConverter boolean support #2181

@CliffAgius

Description

@CliffAgius

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/convertersIssue/Discussion/PR that has to do with ConvertersproposalA fully fleshed out proposal describing a new feature in syntactic and semantic detail

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Completed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions