if "%1"=="debug" (set flags=-t) else (set flags=-t)
-rem Try and run flex. If it is present, great.
-flex %flags% >%2.cpp %3
-if errorlevel 1 goto error
-goto done
+rem Test for presence of flex.
+flex --help >NUL
+if errorlevel 1 goto noflex
-:error
-echo Flex could not run. Using pre-generated files.
-copy %~pn3.cpp %2.cpp
+rem Run flex.
+flex %flags% >%2.cpp %3
+exit
-:done
-exit 0
+:noflex
+echo Flex not found. Using pre-generated files.
+copy %~pn3.cpp.cvs %2.cpp
+exit