Flex+Cygwin --> Error: Exception: STATUS_ACCESS_VIOLATION

Matilla <[email protected]>
Newsgroups gmane.comp.lex.flex.general
Message-ID <[email protected]>
 Hi people
  
  I'm trying to develop a scanner using flex+cygwin, it's just a silly  scanner what i want to do is to store every yytext in a char **tokens  vector. And after generate the lex.yy.c and compile it. The result of  the execution is an error:
  
  4 [main] test 3616 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
  924 [main] test 3616 open_stackdumpfile: Dumping stack trace to test.exe.sta
  ckdump
  
  
  Anybody can help me, please?
  
  This is the .y file:
  
  // Begin File //
  
  %{  
    #include <stdlib.h> /* need this for the call to malloc(), free() */ 
    #include <string.h> /* need this for the call to strcpy() */
  %}
  
  /* Global variables needed in the program */
      char **tokens = NULL;
      int tokensIndex = 0;
  %%
  
  . {
      if ((tokens[tokensIndex] = strdup(yytext)) != NULL) {
              tokensIndex++;
      } else {
          printf("ERROR: While duplicating memory from yytext.\n");
          exit(1);
      }
  }
  
  %%
  
  int main(int argc, char ** argv ) {
      ++argv, --argc;  /* skip over program name */
      if ( argc > 0 ) {
          yyin = fopen( argv[0], "r" );
      } else {
          exit(1);
      }
      
      /* Store the tokens in variable char **tokens */
      yylex();
      
      /* Print all the tokens propertly*/
      int i = 0;
      for(;i<tokensIndex;i++) {
          printf("%s\n",tokens[i]);
          free(tokens[i]);
      }
  }
  
  // End File //
  
  Thanks a lot, for your answers.
  
  
  

		
---------------------------------

LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com

_______________________________________________
Help-flex mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-flex
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.