On Mon, Jan 23, 2012 at 8:07 PM, M Conrad <[email protected]>
 wrote:

>
> Next, if your problem is that you want certain characters to indicate the
> end of a previous loop (like ':' in your case), check out the priority
> system.  If staying in a machine has equal priority with leaving it to go
> to the next, Ragel will do both.  But, if one is prioritized, Ragel will
> pick the transition with higher priority.
>
> Here it'll not work. Priorities prune some branches - this is Ok in some
limited circumstances, but is case like this one you'll get parser which
will start rejecting correct input.

On Mon, Jan 23, 2012 at 8:12 PM, Gerald Gutierrez <
[email protected]> wrote:

>
>
> On 2012-01-23, at 0:26, Victor Khimenko <[email protected]> wrote:
>
> > The answer is simple: you can't. Ragel generates DFA with actions
> attached. This means: symbol in => action out.
> >
> > Your definition is ambigous: when you see a space you have no idea if it
> belongs to the identifier or not. You must scan ahead and look for the next
> non-space char: if it's colon then the previous space was not part of the
> identifier, if it's alnum then it is. This is not something DFA can/should
> do...
>
> Hi Victor,
>
> There is a chapter in the documentation about nondeterminism. Anything
> something there that can help in this situation?
>
> No. The task (as you've formulated it) principally can not be solved using
your definition: to know if identifier is finished or not you need
unlimited lookahead or backtracking.

How would I solve this dilemma? I'll accept the fact that leaving action
can be called many times - this not a problem for me: I'll store beginning
of the identifier in the enter action and the end in the leaving action.
EVERYTHING ELSE I'll move to the action triggered by other elements (colon,
etc). At this point I'll know both beginning and the end of the identifier
and can do whatever I want with it.
_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users

Reply via email to