[ragel-users] Debugging feature for Ragel state machines

Adrian Thurston thurs... at cs.queensu.ca
Mon Aug 13 04:06:18 UTC 2007


TMa wrote:
> 1) optional debug code included in generated files could help
> testing own machines. E.g. a debug message could be printed out
> containing
> current __LINE__,cs, to, stack, fpc and user info text. Currently I
> tried create
> a "$" action but it's not perfect, i think the action is not called
> allways.
> Or am I wrong?

Yes a feature like this is needed. It would be possible to trace states
back to positions in the source ragel file (a single state would map to
multiple positions). A debug feature should print this info as it steps
over input. There is an entry in the TODO to this effect.

The action should be called every time, though if you use a jump or call
and a debug action follows then it will get skipped. You could use $*
instead. This will cause the debug action to be executed before any
transition actions.

> 2) can ragel tell if constructed machine is potentially ambigious and
> where ? It's hard
> to see if there is some problem part and I spent many days attemp/
> mistake to
> get work my machine generated from ABNF.

This kind of feature is also a good idea and I've been wanting to do it
for a while but I haven't gotten to it. My hope is to someday have an
ambiguity report option which tells you which definitions overlap. For
regular languages this is straightforward (though undecidable for CFLs)

In the meantime if you want test if two machines overlap you can use
action embedding operators ($ or $*) to embed named actions and then
look in the intermediate file or the graphviz output for transitions
that execute both of the actions.

Adrian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20070813/6dcfb2f7/attachment-0001.sig>


More information about the ragel-users mailing list