Problem: Change state only when a new input is received

Aditi ad... at cse.iitk.ac.in
Thu Jul 12 08:33:06 UTC 2007


Hi Adrian,
Thanks for you prompt replies :)
@1.) I'll have to test my tool for performance overheads once I finish
it, I hope I would not need this tweaking and it will also be a bit
difficult to do because this is a component of my framework which will
be generated automatically and be used by another component.
@2.) Here is a snippet of ragel code->
<snip>
	action trigger {
		printf("Regex Matched!\n");
	}

	main := any* (2 4 6) @trigger;
</snip>
I am using very simple regex and actions to see if it works. Both of
these are actually going to be user specified and hence more complex.
So, why am I getting a delay of one token? Even the test printf
statement which is printing the tokens is executed only after I send
the next token! :(

@3.) Yeah, It worked; I just had to add any* :)

Thanks again!
Aditi.

On Jul 12, 9:05 am, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
> Hi Aditi,
>
> > 1.) %% write exec will be executed in every iteration of the loop.
> > Will this effect the performance? Is there a better way to do it? I
> > couldn't get it working by putting it just once outside the loop. I am
> > using this to build a tool which is required to be efficient, that's
> > why I am concerned with this point.
>
> As far as I can tell you need the code generated by write exec to run on
> every iteration of the loop. The only consideration here is that there
> will be an unnecessary check of p against pe. In this case pe - p always
> equals one. This should just be a few processor instructions however. If
> you really need to squeeze out instructions and you are concerned you
> can always look at the generated code.
>
> > 2.) The printing of the tokens and the action triggered(as of now,
> > just a print statement) happen only after I send the next token. Why
> > is there this delay of one token in the processing. Is my approach not
> > correct?
>
> My best guess is that you are embedding actions using the '%' operator.
> Provide some ragel code and I'll tell ya for certain :)
>
> > 3.) There are certain other issues also, like I want to match this
> > pattern anywhere in the string and may be multiple times if it occurs.
> > This is not happening here. This code works if I give my pattern in
> > the beginning only. What should I do?
>
> See:
>
> http://groups.google.com/group/ragel-users/browse_thread/thread/8094b...
>
> -Adrian
>
>  signature.asc
> 1KDownload



More information about the ragel-users mailing list