开发者

Ignoring errors in yacc/lex

开发者 https://www.devze.com 2023-01-22 14:14 出处:网络
I\'m new to yacc/lex and I\'m working on a parser that was written by someone else. I notice that when an undefined token is found, the parser returns an error and stops. Is there a simple way to just

I'm new to yacc/lex and I'm working on a parser that was written by someone else. I notice that when an undefined token is found, the parser returns an error and stops. Is there a simple way to just make it ignore completely lines that it cannot parse and 开发者_StackOverflowjust move on to the next one?


just add a rule that looks like

. {
  // do nothing
}

at the bottom of all of your rules, and it will just ignore everything it comes across that doesn't fit any of the previous rules.

Edit: if you have multiple states, then a catch-all that works in any state would then look like:

<*>. {

}
0

精彩评论

暂无评论...
验证码 换一张
取 消