arthanzel / evaluatex

Latex and ASCIIMath evaluator for Javascript.
http://arthanzel.github.io/evaluatex
MIT License
72 stars 16 forks source link

Lexer error: can't match any token #5

Open ghost opened 4 years ago

ghost commented 4 years ago

Whenever I evaluate anything with this library that has a -: in it, it breaks and gives me the error in the title, please help me. For example, if I try to evaluate 1(1)/(5)-:-1(1)/(3) it throws Lexer error: can't match any token.

arthanzel commented 4 years ago

A : is not valid syntax. What behaviour would you expect from 1(1)/(5)-:-1(1)/(3)?

ghost commented 4 years ago

I expect division from -: It is ascii math

arthanzel commented 4 years ago

Touché. Evaluatex only supports the operations described in its manual --- that's not even close to the full feature set of AsciiMath or LaTeX --- because it sufficed for the use case I had for it at the time.

I imagine that the minimum viable change to implement the -: operator would be modifying the lexer to recognize the -: token and emit a / token instead.

Note to self: this is an excellent reason to split the current lexer into AsciiMath and LaTeX lexers, and have them emit a common IR for the parser. Be wary of situations like -:- where the sequence should be interpreted as -: -.

I wish I had the free time to work on Evaluatex, although I would welcome a PR with test cases for the various AsciiMath features. Either way, thanks for bringing up this deficiency.