[ragel-users] parsing c comments
Henrique Pantarotto
ragel at henpa.com
Fri Sep 16 18:48:22 UTC 2011
Thanks Adrian!
By the way, I found this website yesterday:
http://www.mail-archive.com/ragel-users@complang.org/index.html - I found it
very useful for searching ragel's mailing list for help.. the default
mailman archive on your site is awful for searching for stuff and following
a conversation.
Maybe you could consider posting this link on your website, or even better,
migrate the mailing-list and it's archive to google groups... Let me know if
find this idea useful or if you need any help on that.
Thanks again!
On Fri, Sep 16, 2011 at 3:31 PM, Adrian Thurston <thurston at complang.org>wrote:
> Either you have to hack the string you've captured, like you did in this
> solution, or you have to use a scanner. This parsing problem requires
> delaying the action on the first '*' since you don't know if it is a
> containing '*', or the first character in the terminating string.
>
>
> On 11-09-16 11:12 AM, Henrique Pantarotto wrote:
>
>> Well, I solved this problem by using something like this:
>>
>> action mark { text_start = fpc; }
>> action show { printf("'%.*s'\n", fpc - text_start - 1, text_start); }
>>
>> main := '/*' >mark any* :>> '*/' @show;
>>
>> I don't know if this is the "correct way" to solve this, but it worked.
>> ;-)
>>
>>
>> Thanks
>>
>> On Thu, Sep 15, 2011 at 6:37 PM, Henrique Pantarotto <ragel at henpa.com
>> <mailto:ragel at henpa.com>> wrote:
>>
>> Hi, I've read the ragel manual a couple of times and searched the
>> mailing list and I couldn't find the solution to this problem. I
>> imagine the solution is there somewhere, but I couldn't find it
>> since I couldn't search the mailing list archive properly.
>>
>> BTW, I don't really need to parse c comments, but I found this
>> example to match perfectly what I am trying to accomplish. I'm
>> really trying to parse and print data separated by a multi-character
>> token.
>>
>> Page 29 of Ragel 6.7 manual shows an example on how to properly
>> parse C language comments, but the action @comm also parses the *
>> caracter at the ending "*/" as shown in the Graphviz image.
>>
>> I tried many ways to solve this problem, but I couldn't do it. Can
>> someone help?
>>
>> action comm { printf("%c", fc); }
>> p = "/* foo *** bar */";
>>
>> I tried:
>>
>> main := '/*' (any* -- '/*')@comm '*/';
>> main := '/*' any*@comm :>> '*/';
>> main := '/*' ( ( any @comm )* - ( any* '*/' any* ) ) '*/';
>>
>> But it always prints: "foo *** bar *" (note the * at the end) and I
>> looking for a way for it to print just " foo *** bar ".
>>
>> Is there an easy way to fix this?
>>
>>
>> Thanks in advance!
>>
>>
>>
>>
>> ______________________________**_________________
>> ragel-users mailing list
>> ragel-users at complang.org
>> http://www.complang.org/**mailman/listinfo/ragel-users<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<http://www.complang.org/mailman/listinfo/ragel-users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20110916/7ceed48a/attachment-0001.html>
-------------- next part --------------
_______________________________________________
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