Hi, im new to this list, so HELLO everybody. My English is poor so i hope everyone forgive that, thanks! :) I've a question about the struct GScanner. I add a symbol to the struct but, i don't get the G_TOKEN_SYMBOL token. My code is: <<-------------CODE------------------------>> // begin public declartions---------------------------->> enum { SYMBOL_SUMA = G_TOKEN_LAST + 1, SYMBOL_RESTA = G_TOKEN_LAST + 2, SYMBOL_MULTI = G_TOKEN_LAST + 3, SYMBOL_DIV = G_TOKEN_LAST + 4, SYMBOL_DIV_ENT = G_TOKEN_LAST + 5, SYMBOL_POTEN = G_TOKEN_LAST + 6 }; static const struct { gchar *symbol_name; guint symbol_token; } simbolos[] = { { "+", SYMBOL_SUMA, }, { "-", SYMBOL_RESTA, }, { "*", SYMBOL_MULTI, }, { "/", SYMBOL_DIV, }, { "\\", SYMBOL_DIV_ENT, }, { "^", SYMBOL_POTEN, }, { NULL, 0, }, }, *simbolos_p = simbolos; //main function--------------------------------->> GScanner* gscanner = g_scanner_new(NULL); gscanner->config->numbers_2_int = TRUE; gscanner->config->int_2_float = TRUE; gscanner->config->symbol_2_token = TRUE; while (simbolos_p->symbol_name) { g_scanner_scope_add_symbol(gscanner, 0, simbolos_p->symbol_name, simbolos_p->symbol_token); simbolos_p++; } g_scanner_input_text(gscanner, strEntrada, intLongTexto); while (g_scanner_peek_next_token(gscanner) != G_TOKEN_EOF) { if (g_scanner_get_next_token(gscanner) == G_TOKEN_SYMBOL) { g_printf("You have found it!!!"); } } <<------------/CODE------------------------>> I parse a string with an expression (i.e. 2+123/23*12) but the last bucle doesn't find any G_TOKEN_SYMBOL. why is it that way? If anyone can help me i'll be very grateful. Thanks by now! Cheers! Alejandro Cámara Iglesias
Attachment:
pgpXnPggFBlwE.pgp
Description: PGP signature