问题
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