bradhowes / swift-math-parser

Math expression parser built with Point•Free's swift-parsing package

Home Page:https://bradhowes.github.io/swift-math-parser/documentation/mathparser/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Syntax Error Details

alldritt opened this issue · comments

Is there a means of getting the details of a syntax error? Minimally the location of the error within the expression, but also an explanation of the problem (e.g. unrecognized operator, etc.). All I can find is that MathParser.parse() returns nil.

Perhaps MathParser.parse() could return a Result enumeration or throw an exception containing the details of the error.

Hi Mark, this is indeed a glaring omission. I gave some thought at the start of the project, but I went for the quick "return nil on error" since it served my needs.

I've pushed a new 3.4 release with new parseResult and evalResult calls to expose descriptions of the failure cases.