Make generation of nslexer.c more robust.

Ensure that lex errors fail the build instead of being silently ignored
due to the piped call.  Also postpone the update of the nslexer.c file
until we are sure we have generated it properly.

These changes fix some very obscure build failures I encountered while
building FreeBSD within a chroot that did not have devfs mounted. The
specific errors looked like:

.../libc.so.7: undefined reference to `_nsyyerror'
.../libc.so.7: undefined reference to `_nsyyin'
.../libc.so.7: undefined reference to `_nsyylex'
.../libc.so.7: undefined reference to `_nsyylineno'
.../libc.so.7: undefined reference to `_nsyytext'

and were caused due to a mangled nslexer.c being linked into libc.