How to catch all tokens which do not match any grammar in YACC

shankar_vm21@rediffmail.com (Shiva)
27 Apr 2003 02:42:07 -0400

          From comp.compilers

Related articles
How to catch all tokens which do not match any grammar in YACC shankar_vm21@rediffmail.com (2003-04-27)
| List of all articles for this month |

From: shankar_vm21@rediffmail.com (Shiva)
Newsgroups: comp.compilers
Date: 27 Apr 2003 02:42:07 -0400
Organization: http://groups.google.com/
Keywords: parse, yacc, question
Posted-Date: 27 Apr 2003 02:42:06 EDT

Hi ,
I am a new to YACC.


I have written a grammar in YACC which does the parsing of a text
file. Now this text file is having statements which follow a regular
format for which I have written the grammar, but since the text also
has many statements which do not follow any format my parser stops in
middle.Is there any way of catching all the tokens which do not match
any grammar given in YACC so that I can complete the parsing of entire
file.
[There are a variety of approaches. One is to handle it in the lexer,
recognize when you're skipping over stuff and just pass it through
without parsing it. Another is to write generic rules that match
lists of any token, being sure to be sure they stop when it's time
to parse something interesting. -John]



Post a followup to this message

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