n-arms / math-parser

A library to take in a string and output a mathematical result, as well as acting as a Computer Algebra System.
0 stars 0 forks source link

Boolean values and operators (bitwise) #5

Closed n-arms closed 3 years ago

n-arms commented 3 years ago

Description

Handling boolean comparisons between numbers, as well as true/false key variables

Implementation

The lexer should have a static list of keywords, and whenever it detects a would-be symbol with the text of that keyword, it creates a keyword token instead. This includes true and false, which are then handled by the Parser during Parser.parseLiteral().

n-arms commented 3 years ago

By default the ExpressionSyntax.eval() method returns a double, which wouldn't work with a boolean. Similarly, compiling for graphing (#3 ), would involve reducing as much as possible to just constants. It would thus make sense to remove the old eval method and create a new one which returns a tree that is as reduced as possible, a combination of the old eval and reduce methods.