help-bison
[Top][All Lists]
Advanced

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

Flex: token value more than what regexp matches


From: Frans Englich
Subject: Flex: token value more than what regexp matches
Date: Thu, 7 Jul 2005 21:53:18 +0000
User-agent: KMail/1.8.50

Hi,

I have the problem that the value of a token appears to be more than what the 
regexp matches. Here's my (snipped) flex file:

%}
%option 8bit
%option noyywrap
%option nounput


QName   [a-zA-Z-]+:[a-zA-Z-]+
NCName  [a-zA-Z-]+
Digit   [0-9]

%%

{NCName}                        {
                                    XPathlval.sval = XPathtext;
                                    return NCNAME;
                                }
{QName}                         {
                                    XPathlval.sval = XPathtext;
                                    return QNAME;
                                }


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;
}

%token <sval> QNAME
%token <sval> NCNAME


When parsing the expression "fn:false()", I get a QNAME token with the value 
"fn:false" -- what I expect & want.

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?


Cheers,

                Frans




reply via email to

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