davedelong / DDMathParser

String → Number
MIT License
856 stars 153 forks source link

Functions with leading characters that is a registered operator token is not tokenised as a function #109

Closed liaujianjie closed 9 years ago

liaujianjie commented 9 years ago

If I create an operator token as, the string asin(0.5) will be tokenised like this: as in( 0.5 ). Should functions have a higher precedence when tokenizing in Expressionizer?

davedelong commented 9 years ago

That would be one way to solve it. I'll try that out and see what the fallout it.

davedelong commented 9 years ago

Nope; the unit tests prove that operators have to be parsed before identifiers; otherwise you'd never be able to use words as operator tokens; they'd always be recognized as identifiers first.

liaujianjie commented 9 years ago

Also, I noticed that functions are case-insensitive. Is that behaviour necessary? If they aren't then it is possible to free up some characters for use as operators.

For my particular use case, I'm trying to add C and P as binary operators for combination and permutation.

davedelong commented 9 years ago

@liaujianjie I just filed #110 to track case-sensitive functions. I'll keep investigating this operator parsing issue.

davedelong commented 9 years ago

@liaujianjie I've come up with a way to allow for this, and all of the unit tests are still passing. Want to try it out and see if it works for your purposes?

liaujianjie commented 9 years ago

@davedelong Just tested it on my app, works great now. thank you!