How does a parser for the infix notation detect the missing multiplication sign?

本小妞迷上赌 提交于 2019-12-11 20:42:19

问题


I am writing a parser that parses mathematical expressions based on a syntax diagram very similar to this one.

I have not found a way to handle a missing multiplication sign (for example in 3(x+y)). Where in the syntax diagram do I have to handle this?


回答1:


You'd make the * optional in the definition of term.

ASCII diagram:

o-->-->--[factor]->-->--o
    /               \
    \               /
     ---<--[*]--<---
         \     /
          --<--


来源:https://stackoverflow.com/questions/31629984/how-does-a-parser-for-the-infix-notation-detect-the-missing-multiplication-sign

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!