1
votes

Hii,

I have a parser which has many rules and no problem with it its all working.. i am using lex and yacc...

The problem is i want a rule such that if the input string does not match any of the rules defined in the parser then i want to write a rule which will accept such input string..

So basically what i want to do is that i dont want the parser to stop give an error message on itself if the input does not match any other rule, i want to display that error message and then make the parser continue its parsing instead of exiting..

I kno i have to make changes in yyerror() function but how exactly.. or is there any other i can write such a rule...

Thanks.. :)

1

1 Answers

3
votes

You can place the "." (dot) at the end of other parsing rules. It matches any string that has not matched by other rules. See this link for details.

Hope, it's what you meant.

Edit: It seams I have misunderstood. To define default action you can simply put { } action in the parser file. See here.