<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
p.gmail-p1, li.gmail-p1, div.gmail-p1
        {mso-style-name:gmail-p1;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.gmail-s1
        {mso-style-name:gmail-s1;}
span.gmail-apple-converted-space
        {mso-style-name:gmail-apple-converted-space;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Is the sink executing as you intend?&nbsp; If not, it could be because when the hook “on %init” is executed when the routine is initialized, but at that time, the element “wss_data”
 has not been parsed yet.&nbsp; Perhaps try:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;">on wss_data {<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="gmail-s1">self.sub.connect(new Sub());<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span class="gmail-s1"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.sub.write(self.wss_data);<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span class="gmail-s1"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;">}<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Mark<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> hilti-bounces@ICSI.Berkeley.EDU [mailto:hilti-bounces@ICSI.Berkeley.EDU]
<b>On Behalf Of </b>Jennifer Gates<br>
<b>Sent:</b> Thursday, July 27, 2017 2:56 PM<br>
<b>To:</b> Robin Sommer &lt;robin@icir.org&gt;<br>
<b>Cc:</b> hilti@ICSI.Berkeley.EDU<br>
<b>Subject:</b> Re: [HILTI] Spicy Parsing WebSockets - how to end a list<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">Thanks for the response.&nbsp; Unfortunately, the &amp;eod doesn't work with a list, just with bytes.&nbsp; 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.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Last night I started down another path. I am trying to use a sink construct.&nbsp; Here is some of the code:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<p class="gmail-p1"><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">export type WS_Handshake_Success = unit {</span></span><o:p></o:p></p>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">success
</span></span><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">: /^(HTTP|http)/;</span></span><o:p></o:p></p>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">dvalue</span></span><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">: DataValue;</span></span><o:p></o:p></p>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">svrheaders
</span></span><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">: list&lt;Header&gt; ;</span></span><o:p></o:p></p>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">end_of_hdrs : /\x0d\x0a\x0d\x0a/;</span></span><o:p></o:p></p>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">wss_data : bytes &amp;eod &amp;convert=terminate($$) &amp;transient -&gt; self.sub;</span></span><o:p></o:p></p>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">on %init {</span></span><o:p></o:p></p>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">self.sub.connect(new Sub());</span></span><o:p></o:p></p>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; &nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">}</span></span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;;color:black">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></span><span style="font-family:&quot;Courier New&quot;;color:black">var sub: sink;</span><span style="font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">};</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="gmail-p1"><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">export type Sub = unit {</span></span><o:p></o:p></p>
</div>
</blockquote>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<blockquote style="margin-left:30.0pt;margin-right:0in">
<div>
<p class="gmail-p1"><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">ws_msgs : list&lt;WS_Message&gt;;</span></span><o:p></o:p></p>
</div>
</blockquote>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<div>
<p class="gmail-p1"><span class="gmail-apple-converted-space"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp;
</span></span><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">: DataEnd;</span></span><o:p></o:p></p>
</div>
</blockquote>
</blockquote>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<div>
<p class="gmail-p1"><span class="gmail-s1"><span style="font-family:&quot;Courier New&quot;">};</span></span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</blockquote>
<p class="MsoNormal">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.&nbsp;<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">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 &quot;print self&quot; statement of the WS_Handshake just lists sub=&lt;sink&gt;. To get the individual list items to show I need
 to print the sub unit.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Is there a way to make the Sub unit a part of the WS_Handshake unit?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Thank you,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Jenn<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>