[ragel-users] Writing a Telnet parser

Adrian Thurston adrian.thurston at esentire.com
Wed Sep 29 17:07:07 UTC 2010


Hi Jonathan,

Ragel does not do any buffering of text for you. It's up to you to 
decide how you want to do that, then implement it yourself. There are a 
couple options. You can copy text to a buffer as you move over 
characters, or you can extract them from the input buffer when you need 
them. The first approach is simpler and guaranteed to work without 
hitches. The second technique is faster, but you have to consider buffer 
block boundaries.

-Adrian

On 10-09-28 08:30 PM, Jonathan Castello wrote:
> Hello,
>
> I'm building a Telnet parser using Ragel, and I'm having an issue
> making the actions do what I want. I've pasted the machine definition
> to a gist: http://gist.github.com/602242
>
> The issue is a little hard for me to describe, so I'll try to
> illustrate it as best as I can. If I have a stream of input, and some
> part of it is "abcdef<IAC><GA>ghi" (where<x>  is a mnemonic for a
> single byte), I want to emit events as such: text("abcdef"),
> command("<GA>"), text("ghi"). The caller provides callbacks, and I
> would pass the data to them as I interpret it.
>
> The problem is that I can't figure out how to define actions that
> would only trigger when the next character doesn't match plain_text
> (or there's no more data left to parse in that particular packet), so
> I can get that full stretch of characters. At the moment, I can only
> get text("a"), text("b"), text("c") etc. to work, i.e. one plain_text
> match at a time.
>
> I suspect the problem is that cr_sequence and iac_sequence are
> supposed to behave this way - they, too, match singular "terms" each
> time before returning to the start - but here I am, wanting to give
> plain_text special treatment. Am I even coming at this from the right
> angle?
>
> Thanks in advance for any advice!
> ~Jonathan Castello
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> 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



More information about the ragel-users mailing list