You're right there is an inconsistency here and it is because he
ordering algorithm doesn't accommodate the backwards references in the
epsilon transition. This should most certainly be fixed.
-Adrian
On 12-07-09 04:55 PM, Murray Henderson wrote:
Hello,
Consider the following test program:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
%%{
machine chart;
write data;
}%%
void test( char *str )
{
char *p = str, *pe = str + strlen( str ), *eof = pe;
int cs;
%%{
action s { putchar('s'); }
action e { putchar('e'); }
action nl { putchar('\n'); }
main := (
start: '' -> a,
a: 'aa' >s %e -> b,
b: 'bb' >s %e -> a
) $/nl;
# Initialize and execute.
write init;
write exec;
}%%
};
int main()
{
test( "aabba" );
return 0;
}
Intuitively I expected the above program to print "seses", but it prints
sesse".
From the Ragel manual:
"""
We associate with the embedding of each action a unique timestamp that
is used to order
actions that appear together on a single transition in the final state
machine. To accomplish
this we recursively traverse the parse tree of regular expressions and
assign timestamps to action
embeddings. References to machine definitions are followed in the
traversal. When we visit a parse
tree node we assign timestamps to allenteringaction embeddings, recurse
on the parse tree, then
assign timestamps to the remainingal l,finishing, andleavingembeddings in
the order in which
they appear.
"""
So what I am guessing is happening is that the action '>s' in state 'a'
is getting a timestamp earlier than action '%e' in state 'b', and will
therefore always execute before '%e' in state 'b'.
Logically, shouldn't '%' actions execute before '>' actions?
Cheers,
Murray
_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users
_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users