[ragel-users] Parsing of names with spaces in them

Victor Khimenko khim at chromium.org
Mon Jan 23 16:31:19 UTC 2012

On Mon, Jan 23, 2012 at 8:07 PM, M Conrad <silverdirk-rgl at silverdirk.com>

> 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 <
gerald.gutierrez at gmail.com> wrote:

> On 2012-01-23, at 0:26, Victor Khimenko <khim at chromium.org> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20120123/ec6f5cbe/attachment-0001.html>
-------------- next part --------------
ragel-users mailing list
ragel-users at complang.org

More information about the ragel-users mailing list