home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 10 Scripting / 02 Berger / scc / SCC.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-09  |  915 b   |  34 lines

  1. #include <stdio.h>
  2.  
  3. #include "SCC.H"
  4.  
  5.  
  6. // Flex reads the 'yyin' file handle for input.  'yyin' will be defined in
  7. // the generated scc-lexer.cpp file, so we'll need to extern the variable.
  8. extern FILE *yyin;
  9.  
  10.  
  11. int main( int argc, char **argv )
  12. {
  13.   // The usage for this program is pretty simple.  If no arguments are given
  14.   // to the program, then it will expect input on stdin (this is the default
  15.   // value of 'yyin').  If there was an argument specified, then this will
  16.   // specify the source file name to read from.
  17.   if ( argc == 2 ) {
  18.     // Open the given file name for reading.
  19.     yyin = fopen( argv[1], "r" );
  20.  
  21.     // If the file could not be opened, then inform the user and terminate the
  22.     // program.
  23.     if ( yyin == NULL ) {
  24.       perror( argv[1] );
  25.       return 1;
  26.     }
  27.   }
  28.  
  29.   // Call into Bison to tell it to parse the input file.
  30.   yyparse();
  31.  
  32.   return 0;
  33. }
  34.