help-bison
[Top][All Lists]
Advanced

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

RE: Flex: token value more than what regexp matches


From: Vincent Zweije
Subject: RE: Flex: token value more than what regexp matches
Date: Fri, 8 Jul 2005 11:43:34 +0200

Frans Englich wrote:

> The relevant parts in my Bison is:
>
> %union
> {
>     int ival;
>     char *sval;
>     KDOM::XPath::ExpressionImpl *expr;
>     KDOM::XPath::ExpressionImpl::List *expressionList;    
>     QPSingleType *singleType; KDOM::XPath::SharedQName *qName;
>     bool emptyAllowed;
> }

> However, when parsing the expression "false()", I get the
> token NCNAME with
> the value "false(". The token is right, but I don't want the
> parantese to be included.
>
> Why is the parantese included in the value, and how do I fix
> it? The regexp
> "[a-zA-Z-]+" really shouldn't match it, right?

This is really a FAQ.

Flex overwrites the '(' with a null character when it
passes the token to bison.
Your bison rule stores only the pointer to the string.
By the time the bison parser gets around to printing
your token (one token later), flex has restored the
'(' character (and overwritten the ')' character).

To fix, save the contents of the string instead of only
the pointer to it.

Vincent Zweije
Development
-- 
WCC Services - Advanced Matching Technology
NL  +31 30 7503222
address@hidden
www.wcc-group.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]