From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#23019: parse-partial-sexp doesn't output the full state needed for its continuance. Date: Fri, 18 Mar 2016 15:11:55 +0000 Message-ID: <20160318151154.GA9433@acm.fritz.box> References: <20160315091355.GA2263@acm.fritz.box> <20160317214934.GB9038@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1458313840 31615 80.91.229.3 (18 Mar 2016 15:10:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Mar 2016 15:10:40 +0000 (UTC) Cc: 23019@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 18 16:10:24 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1agw2f-0008TQ-48 for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Mar 2016 16:10:21 +0100 Original-Received: from localhost ([::1]:44322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agw2Z-0004QY-Ga for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Mar 2016 11:10:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agw2Q-0004Kd-Lg for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2016 11:10:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agw2M-0006gG-L0 for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2016 11:10:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agw2M-0006gC-Ij for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2016 11:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1agw2M-0003L6-Fl for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2016 11:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Mar 2016 15:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23019 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23019-submit@debbugs.gnu.org id=B23019.145831375312774 (code B ref 23019); Fri, 18 Mar 2016 15:10:02 +0000 Original-Received: (at 23019) by debbugs.gnu.org; 18 Mar 2016 15:09:13 +0000 Original-Received: from localhost ([127.0.0.1]:52783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agw1Z-0003Jy-0L for submit@debbugs.gnu.org; Fri, 18 Mar 2016 11:09:13 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:48652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agw1X-0003Jq-RT for 23019@debbugs.gnu.org; Fri, 18 Mar 2016 11:09:12 -0400 Original-Received: (qmail 21732 invoked by uid 3782); 18 Mar 2016 15:09:09 -0000 Original-Received: from acm.muc.de (p548A53B1.dip0.t-ipconnect.de [84.138.83.177]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 18 Mar 2016 16:09:07 +0100 Original-Received: (qmail 9531 invoked by uid 1000); 18 Mar 2016 15:11:55 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:115031 Archived-At: Hello, Stefan. On Fri, Mar 18, 2016 at 12:49:07AM -0400, Stefan Monnier wrote: > > Do this by adding two new fields to the parser state: the syntax of the last > > character scanned, and the last end of comment scanned. This should make the > > parser state complete. > Thanks. I like the "syntax of the last character scanned", but I don't > understand the reasoning behind "last end of comment scanned". Why is > this relevant? Is it in case the "last character scanned" was a "slash > ending a comment" so as to avoid treating "*/*" as both a comment closer and > a subsequent opener? That's exactly the reason. > If so, I'm not sure I like it. I don't really like it either. > It sounds to me like there's a chance it's actually incomplete (e.g. > it doesn't address the similar problem when the "last character > scanned" is an end of a string which also happens to be a valid > first-char of a comment-starter), and even if it isn't, it "feels > ad-hoc" to me. Now even I wouldn't have come up with that end-of-string scenario. ;-) Such a scenario is presumably one reason why, in scan_sexps_forward, two character comment delimiters are handled before strings. > Would it be difficult to do the following instead: > - get rid of element 11. Done. > - change element 10 so it's nil if the last char was an "end of > something". Another way to look at it, is that the element 10 should > only be non-nil if the "next lexeme" might start on that > previous character. I've tried this, and it's somewhat ugly. Setting the "previous_syntax" to nil is also needed for the asterisk in "/*". The nil would appear to mean "the syntactic value of the last character has already been used up". So the "previous_syntax" is nil in the most interesting cases. It also feels somewhat ad-hoc. How about this idea: element 10 will record the syntax of the previous character ONLY when it is potentially the first character of a two character comment delimiter, otherwise it'll be nil. At least that's being honest about what the thing's being used for. > I also have a side question: IIUC your patch makes the 5th element > redundant (can be replaced with a test whether "last char syntax" was > "escape"), is that right? It would appear to be, yes. We really can't get rid of element 5, though, because there will surely be code out there that uses it. But if I change element 10 as outlined above, element 5 will no longer be redundant. > Stefan -- Alan Mackenzie (Nuremberg, Germany).