<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 19, 2013, at 4:22 PM, Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div><br class="Apple-interchange-newline">On Mar 19, 2013, at 2:58 PM, jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><br>On Mar 19, 2013, at 2:29 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><br><blockquote type="cite"><br>On Mar 19, 2013, at 14:21 , jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:<br><br><blockquote type="cite"><br>On Mar 19, 2013, at 1:42 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><br><blockquote type="cite"><br>Would it make sense to not just continue but to pretend instead that the '}' is there? I feel like that will give us better recovery. (You'd eliminate those last two errors: "expected '}'" and "missing '@end'".)<br></blockquote><br>I think by 'pretending' you mean insert a '}' before @end and continue. I thought about this but  I did not want to introduce the bookkeeping<br>overhead for the correct case. Do you have a suggestion how to pretend without adding this overhead?<br></blockquote><br>Hm, I see what you mean—right now we unilaterally consume a closing brace when we exit the loop. The easiest way to solve this is to extract the parsing loop and the T.consumeClose() into a helper function, with an early return for the @end case...but that's not exactly pretty. I guess I'll let you make the call (or stand by the call you already made).<br></blockquote><br>Problem is not avoiding calling of T.consumeClose() in the incorrect case. Problem is that '@' and 'end" are two tokens and we have consumed<br>'@' already  (this will cause parse error later).  I see two solutions:<br>1. When seeing '@', lookahead for 'end' and exit the loop while skipping T.consumeClose() . I think this is what you are suggesting. But it involves unnecessary overhead for the common case.<br>2. If it is possible,  I can insert a '}' two tokens before current token and reset the lexer to the inserted '}'  for the incorrect case, then problem is solved without introducing any undue overhead for<br>   the common case.<br></div></blockquote></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><br></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">You don't need to insert the '}' token. If you've consumed the '@' and see something that doesn't belong in a list of instance variables (e.g., 'property', 'end'), break out of the loop without calling consumeClose() and then PP.EnterToken() the '@' to recover.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"></blockquote><div><br></div>Yes, this API was what I was wishing for. It was more involved than I bargained for because I did not want to introduce</div><div>any overhead in the loop for the common case. In r177549.</div><div><br></div><div>-Thanks to both</div><div>   - Fariborz<br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>- Doug</div></blockquote></div><br></body></html>