[ragel-users] Default actions that leave the machine

Adrian Thurston adrian.thurston at esentire.com
Mon Jan 31 17:58:22 UTC 2011


Hi, have you looked at ragel's local and global error actions yet? These 
may do what you want.

-Adrian

On 11-01-26 08:08 PM, Murray Henderson wrote:
> Hello,
>
> I want to embed a default action into a machine that leaves the
> machine (without using manual a jump inside the action).
>
> For simplicities sake, I will call this operator $^^ (since it is
> similar to the Local Error operator).
>
>
> Example:
>
> action parse_error {}
> helloworld = ('HELLO ' %^^parse_error) 'WORLD';
>
> Non-error inputs include:
> HELLO WORLD
> HELLOWORLD (parse_error action occurs on 'O' ->  'W' transition)
> HELLWORLD (parse_error action occurs on 'L' ->  'W' transition)
> HELWORLD (parse_error action occurs on 'L' ->  'W' transition)
> HEWORLD (parse_error action occurs on 'E' ->  'W' transition)
> HWORLD (parse_error action occurs on 'H' ->  'W' transition)
> WORLD (parse_error action occurs on ->  'W' transition)
>
>
> I can simulate the above behavior with the '?' operator, but that is
> laborious, and there are other ways of using $^^ that I suspect cannot
> be simulated.
>
>
> I want this operator because I am trying to make a liberal parser that
> accepts all possible input. (Every state must have a default action)
> .I am creating a html5 parser that uses regular machines for
> tokenizing, and scanners built from the regular machines for parsing.
> Yes, I am mad.
>
> I cannot use manual jumps, because I don't want to jump out of the
> scanners mid-token.
>
>
> I am willing to try and add this operator into Ragel myself. I have
> grabbed the source code and tracked my way to fsmap.cpp, where the new
> operator would be added.
>
> Before I continue...
> Is there already a way to achieve my desired behavior that I am not aware of?
> Would such an operator be worthwhile? Is it even possible?
> Is there any knowledge that could be imparted that would help me make a patch?
>
> If I do end up making a patch, for symmetry purposes I will make
> global/local and start/any/final etc versions of the operator.
>
> After a brief look through the source, it looks like I would need to
> mod the FsmAp::fillGaps() function, passing in a (separate object for
> each?) final state into the FsmAp::attachNewTrans() instead of NULL.
>
> Ragel is a wonderful program by the way, thank you for creating it.
>
> Cheers,
> Murray
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users
>

_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users



More information about the ragel-users mailing list