[ragel] sample code

xoru xoru at onet.pl
Mon Feb 12 08:58:19 UTC 2018

Many thanks. This work fine. I would like to thank you very much for your help. I have been struggling with this problem for a long time. I will go from bison, because unfortunately when bison have mistakes it publish messages to stdout and I want to emmbeding them in the program. Do not they write anything in the ragel?
I add a information if there is a problem or not.
  if ( cs < %%{ write first_final; }%% )
   printf("\x1B[31mProblem\x1B[0m [%d]\n", %%{ write error; }%%);
this is correct?
There is a phrase in the code:
"write data noerror nofinal;"
Is it correct?
"noerror is neccesary? "nofinal" ?
I working on comments but this is not important.
You've helped me a lot, thank you.
Marek Łukasz
W dniu 2018-02-07 17:08:54 użytkownik Adrian Thurston <thurston at colm.net> napisał:
It's because space* accepts the zero-length string. So "abc" is actually three words with zero-length whitespace in between. Well, technically it's both that and what you want, so you need to remove the ambiguity. What you need is more like this:
space* wyraz ( space+ wyraz )*
On 2018-02-05 07:06, xoru wrote:
How put "a ab abc \t abcd\n abcde"
and get
When i use main := (space* wyraz )* i get only chars not words
/* @LANG: c */ #include <stdio.h> #include <string.h> %%{ machine foo; action beginning { pocz = p; } action ending { printf("'%.*s'\n",(int)(p - pocz), pocz); } wyraz = [a-z]+ >beginning %ending; main := ( space* wyraz ) ; write data noerror nofinal; }%% int main(int argc, char **argv) { int cs = 0; char *pocz; if (argc > 1) { char *p = argv[1]; char *pe = p + strlen(p); char *eof = pe; %%write init; %%write exec; } return 0; }
_______________________________________________ ragel mailing list ragel at colm.net http://www.colm.net/cgi-bin/mailman/listinfo/ragel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20180212/6528cf33/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rl.2018-02-12.1518425844.tgz
Type: application/x-compressed-tar
Size: 842 bytes
Desc: not available
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20180212/6528cf33/attachment-0002.bin>

More information about the ragel-users mailing list