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

Gerald Gutierrez gerald.gutierrez at gmail.com
Mon Jan 23 07:11:28 UTC 2012

Hello folks,

I recently found Ragel and have discovered that it is a very pleasant
piece of software. That said, I've run into a problem that I was
hoping is common and a solution available.

Please see the example code at https://gist.github.com/1661150.

Basically, I'd like to parse the following:


where the names start and end with an alnum, and can contain any
combination of alnum and spaces inside. They could also be blank. My
rules for this are:

identifier = alnum (space* alnum)*;
name       = (identifier | zlen) >sName $pName %fName;

The names can be separated by a colon and optionally spaces inbetween
the names and the colon. My rules for this are:

sep = space* ":" space*;
main := name sep name;

This doesn't work because apparently the space* in identifier and the
space* in sep confuse the parser. I end up getting the action fName
executed in every space of the name.

If I change sep to:

sep = ":";

then everything is fine. How do I modify these rules so that the
parser does what I intend?

ragel-users mailing list
ragel-users at complang.org

More information about the ragel-users mailing list