| Related articles |
|---|
| How to handle comment using lex/yacc? cylin@avant.com.tw (cylin) (2004-01-09) |
| Re: How to handle comment using lex/yacc? a7244270@yahoo.com (2004-01-16) |
| From: | a7244270@yahoo.com (Alfonso Urdaneta) |
| Newsgroups: | comp.compilers |
| Date: | 16 Jan 2004 22:23:49 -0500 |
| Organization: | http://groups.google.com |
| References: | 04-01-040 |
| Keywords: | yacc, parse |
| Posted-Date: | 16 Jan 2004 22:23:49 EST |
> When I parse this text file,the first line always is right,
> but the second line ayways gets syntax error.
> How to fix my lex and yacc file?? Thx.
... snip....
> top_rule:
> | slice_rule {ignoreComment('\n');}
> ;
It hasn't got anything to do with the comment - it's failing because
according to your grammar, only a single line of input is valid.
top_rule: slice_rule
| top_rule slice_rule
;
The above will work for you (I think, didn't test), but its a little
different from what's in the manual's first sample , which looks kind
of like so:
input: /* empty */
| input line
;
line: /* put your stuff here */
| /* some more stuff */
;
Regards,
--
alfonso e. urdaneta
Return to the
comp.compilers page.
Search the
comp.compilers archives again.