[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Flex+Cygwin --> Error: Exception: STATUS_ACCESS_VIOLATION
From: |
Matilla |
Subject: |
Flex+Cygwin --> Error: Exception: STATUS_ACCESS_VIOLATION |
Date: |
Wed, 1 Feb 2006 13:29:09 +0100 (CET) |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Flex+Cygwin --> Error: Exception: STATUS_ACCESS_VIOLATION,
Matilla <=