| Related articles |
|---|
| Unable to use error recovery with bison f.tomassetti@gmail.com (2005-04-11) |
| Re: Unable to use error recovery with bison haberg@math.su.se (2005-04-16) |
| Re: Unable to use error recovery with bison f.tomassetti@gmail.com (2005-04-26) |
| From: | haberg@math.su.se (Hans Aberg) |
| Newsgroups: | comp.compilers |
| Date: | 16 Apr 2005 21:33:34 -0400 |
| Organization: | Mathematics |
| References: | 05-04-024 |
| Keywords: | yacc, parse |
| Posted-Date: | 16 Apr 2005 21:33:34 EDT |
f.tomassetti@gmail.com (Federico Tomassetti) wrote:
> I spent the last days trying to make error recovery working but I
> can't catch one and yyerror is always invoked:
>
> I report a portion from the lex source, yacc source and file parsed.
>
> I always obtain the message "syntax error, unexpected NEWLINE,
> expecting SPACE"
Looking at your grammar, you have
voidspace: SPACE | TAB | NEWLINE
;
thus only admitting eaxctly one of the three, for example in your rule
class_decl_header:
KWCLASS SPACE CLASSNAME
You probably want any number of these.
It is common to let the lexer zip out the whitespace by .l rules:
[ \f\r\t\v]+ {}
\n+ {}
The idea here is to also break up longer rule matches, as the Flex
generated lexer otherwise may get into buffer problems, slowing it down.
--
Hans Aberg
Return to the
comp.compilers page.
Search the
comp.compilers archives again.