Re: GScanner



I can't answer all of your questions, as I've never used GScanner.

On Tue, Jul 02, 2002 at 11:33:58AM -0500, Ronald Roth wrote:
2) Also, when I call g_scanner_cur_value, what does the returned union
contain?  For example, if the TokenType is G_TOKEN_IDENTIFIER, does the
returned union contains NULLS for all fields except the v_identifier
field?  Or does it somehow fill in all of the fields?

I think you could arrive at this answer if you thought about it again.

In case you cannot, a C union-type defines a set of types that all
take up the same storage location. If v_identifier is set, v_symbol,
etc. are also set. However, as the token is a G_TOKEN_IDENTIFIER,
the other types make no sense, and should not be used.

To prove this to yourself, try sizeof(GTokenValue). Even though the
union has 11 fields, my quick estimate suggests that the size of the
union is 8 bytes.

3) could someone explain to me what the "scanner scope" is?

As I mentioned earlier, I've never used GScanner, however, I would
guess that tokens can be defined as being significant only in certain
'scanner scopes'. The set_scope method allows you to instruct the
scanner which scope it should operate in for determining the next
token.

An example of this might be (not sure if this is actually efficient)
for one scope to be the RFC822 header field name, the next scope to be
the RFC822 header field value, the next scope to be the RFC822 body.

in case it matters, I am attempting to parse mbox's.  I trying to follow
the rules specified in RFC822.

Personally, I would probably code an RFC822 parser from scratch... The
rules are so arbitrary and changing that a generic parser could not
possible do anywhere close to as good a job in terms of performance.
(I could be wrong...)

mark

-- 
mark mielke cc/markm ncf ca/markm nortelnetworks com __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]