[HILTI] Spicy Parsing WebSockets - how to end a list

Jennifer Gates jenngates2004 at gmail.com
Thu Jul 27 11:55:31 PDT 2017

Thanks for the response.  Unfortunately, the &eod doesn't work with a list,
just with bytes.  Because the end of the connection is simply the end of
the last byte of actual data, there is no look-ahead token for the list to
work. At least that is what it seems to me.

Last night I started down another path. I am trying to use a sink
construct.  Here is some of the code:

export type WS_Handshake_Success = unit {

        success     : /^(HTTP|http)/;

        dvalue      : DataValue;

        svrheaders     : list<Header> ;

        end_of_hdrs : /\x0d\x0a\x0d\x0a/;

        wss_data : bytes &eod &convert=terminate($$) &transient -> self.sub;

        on %init {

                self.sub.connect(new Sub());

        var sub: sink;

export type Sub = unit {

ws_msgs : list<WS_Message>;

    : DataEnd;


The terminate function appends a byte sequence (constant DataEnd) to the
raw bytes that I can then use to identify the end of the data when parsing
the messages in the Sub unit. That way the WS_Messages are properly parsed
within the Sub unit.

The only piece that I'm working on now is how to put that parsed data back
into the original WS_Handshake unit. Right now a "print self" statement of
the WS_Handshake just lists sub=<sink>. To get the individual list items to
show I need to print the sub unit.

Is there a way to make the Sub unit a part of the WS_Handshake unit?

Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ICSI.Berkeley.EDU/pipermail/hilti/attachments/20170727/d5954208/attachment.html 

More information about the HILTI mailing list