Hi, can any guru give some suggestion on how to develop a smart parser/ compiler given a set of syntax definition? By "smart" I mean the parser can skip some errors and continue, like gcc does in some situation. I hope to learn some general principles on this issue. Thanks!
i did one before and can do it for you Email:g**********[email protected]
【在 c****7 的大作中提到】 : 有人会吗?要求功能类似IE的BHO。请站内联系。谢谢!
c*t
7 楼
For LR parsers, when a set of tokens couldn't be reduced, there is a error. At this point, you can decided on a case by case basis to manipulate the parsing stack or directly generate an error. For LL parsers, if your look ahead token isn't what you expect (such as missing ';'), you can insert this pretty easily. Usually LL parsers is a bit easier for this kind of stuff. I'd say don't waste your time on itt. It's really not that importat.
【在 g*********s 的大作中提到】 : Hi, can any guru give some suggestion on how to develop a smart parser/ : compiler : given a set of syntax definition? : By "smart" I mean the parser can skip some errors and continue, like gcc : does in some situation. I hope to learn some general principles on this : issue. : Thanks!
c*7
8 楼
你好,我回了你的信,请问收到了吗?
【在 j****a 的大作中提到】 : i did one before and can do it for you : Email:g**********[email protected]
d*2
9 楼
bison supports "error" token, you can do whatever you want.
N*n
10 楼
The idea is simple: Add additional rules to track potential errors. Like switch case statements: switch (status) case 0 : // do status 0 ... case 1 : // do status 1 ... case 2 : // wrong, status 2 is caused by some certain mistake generateErrorReportOnStatus2 (); ... ... "case 2" is an example of the additional rules.
【在 g*********s 的大作中提到】 : Hi, can any guru give some suggestion on how to develop a smart parser/ : compiler : given a set of syntax definition? : By "smart" I mean the parser can skip some errors and continue, like gcc : does in some situation. I hope to learn some general principles on this : issue. : Thanks!