Re: [gtk-list] Re: g_scanner funtions what for?
- From: Andreas Tille <tille physik uni-halle de>
- To: GTK User-List <gtk-list redhat com>
- Subject: Re: [gtk-list] Re: g_scanner funtions what for?
- Date: Tue, 16 Mar 1999 21:40:54 +0100 (MET)
On Fri, 12 Mar 1999, Tim Janik wrote:
> your modifications:
>
> /* some test text to be fed into the scanner */
> static const gchar *test_text =
> ( "Datum: 02-16-1999\n"
> "Probenname: Hans_1\n"
> "Modulator f: 500.0\n"
Changed to: Modulator_f
> "Schwingkreis f: 500.0\n"
Changed to: Schwingkreis_f
> "Schwingkreis U: 5.0\n"
Changed to: Schwingkreis_U
> "Temperatur: 25.0\n"
> "Trigger-Delay: -400\n"
Changed to: Trigger_Delay
> "Punktzahl: 8192\n"
> "Messzeit: 2.0e-006\n" );
>
> "Schwingkreis f" can't be scanned as a single token, because a GScanner
> will skip spaces by default and not feature spaces as a valid symbol char.
>
> when you create a new scanner, g_scanner_new() accepts a pointer to a
> GScannerConfig structure that contains various default values for its
> scanning behaviour. if you pass that structure as NULL, gscanner.c will
> revert to a default structure, defined in gscanner.c:
I hope to fit the requirements for the tokens so far. Note that I
didn't ended the lines with ';' (is this required?).
> also, you have to adapt parse_symbol() so it parses tokens other than float as
> well, instead of:
>
> /* expect a valid symbol */
> g_scanner_get_next_token (scanner);
> symbol = scanner->token;
> if (symbol < SYMBOL_DATE ||
> symbol > SYMBOL_T)
> return G_TOKEN_SYMBOL;
>
> ...
Hmm, I've done that but my program dosn't reach this point. It returns
with error code for before that stuff.
I tried
/* expect a float (ints are converted to floats on the fly) *or* a string */
g_scanner_get_next_token (scanner);
if (scanner->token != G_TOKEN_FLOAT || scanner->token != G_TOKEN_STRING )
return G_TOKEN_FLOAT;
read floats *AND* strings but failed and I get
test text:1: error: unexpected string constant "J02161999", expected number (float)
If I set "Datum: J02161999\n" (the '-' int the former string caused trouble)
or
test text:1: error: scanner: digit is beyond radix
if I leave "Datum: 02161999\n" ... a string of spaces only. I expect
that I have to configure the scanner to read strings (like a date or
a name), but I can't find any way how to do that.
Kind regards
Andreas.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]