Re: How to handle comment using lex/yacc? (Alfonso Urdaneta)
16 Jan 2004 22:23:49 -0500

          From comp.compilers

Related articles
How to handle comment using lex/yacc? (cylin) (2004-01-09)
Re: How to handle comment using lex/yacc? (2004-01-16)
| List of all articles for this month |

From: (Alfonso Urdaneta)
Newsgroups: comp.compilers
Date: 16 Jan 2004 22:23:49 -0500
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 */


alfonso e. urdaneta

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.