Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

yywrap()

When a lexer encounters an end of file, it optionally calls the routine yywrap() to find out what to do next. If yywrap() returns 0, the scanner continues scanning, while if it returns 1, the scanner returns a zero token to report the end-of-file. If your lexer doesn’t use yywrap() to switch files, the option %option noyywrap removes the calls to yywrap(). The special token <<EOF>> is usually a better way to handle end-of-file situations.

The standard version of yywrap() in the flex library always returns 1, but if you use yywrap(), you should replace it with one of your own. If yywrap() returns 0 to indicate that there is more input, it needs first to adjust yyin to point to a new file, probably using fopen().


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint