help-bison
[Top][All Lists]
Advanced

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

Reuse of scanner within bison?


From: Arno Wilhelm
Subject: Reuse of scanner within bison?
Date: Thu, 22 Jun 2006 11:54:19 +0200
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929)

Hello,


I am kind of a "bison newbie" and have reached a point where I thought it would 
be better to ask someone for help ;-).

Here we go:

There is a class filterValidator that get's a rule which has to be applied 
several times against a given filter object.
When the rule applies to the filter it returns 1, else 0.

- In the class filterValidator a string (=rule) is passed to the constructor, 
where it again is passed to yy_scan_string().

filterValidator::filterValidator( const char* const rule )
{
    buffer_ = yy_scan_string( rule );
}

- Any time the method validateFilter() is called the passed filter object has 
to be validated against the rule
(- which has been passed in the constructor -) and if the rule applies to the 
filter the method returns 1, else 0.

int filterValidator::validateFilter( const Cfilter* const filter )
{
     return yyparse( (void*) filter );
}

- In the destructor the YY_BUFFER_STATE is goint to be deleted:

filterValidator::~filterValidator()
{
    yy_delete_buffer( buffer_ );
}


The point is that the rule should be only parsed once in the constructor and 
reused several times in the method validateFilter().
The first call to validateFilter() works, but any successive returns with a 
syntax error:
"syntax error, unexpected $end, expecting SLASH".

I guess that the scanner has reached the end of the rule and does not start 
from the beginning again ?
Is there a way to restart the scanner again ? I have tried out yyrestart() but 
only got a segfault.
Any help would be appreciated.


Thanks and regards,
Arno





reply via email to

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