From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Damien Cassou Newsgroups: gmane.emacs.devel Subject: Parsing beyond sexps Date: Sun, 19 Jan 2020 09:11:50 +0100 Message-ID: <87wo9nn9vd.fsf@cassou.me> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="69759"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jan 19 09:12:34 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1it5hB-000I61-2R for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Jan 2020 09:12:33 +0100 Original-Received: from localhost ([::1]:48310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1it5hA-0004BA-3d for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Jan 2020 03:12:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42657) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1it5gh-0003lE-Cx for emacs-devel@gnu.org; Sun, 19 Jan 2020 03:12:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1it5gg-00076x-1E for emacs-devel@gnu.org; Sun, 19 Jan 2020 03:12:03 -0500 Original-Received: from mail.choca.pics ([80.67.172.235]:39896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1it5gf-0006uZ-RS for emacs-devel@gnu.org; Sun, 19 Jan 2020 03:12:01 -0500 Original-Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 60E8F181A505A for ; Sun, 19 Jan 2020 09:11:52 +0100 (CET) Original-Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id sEb6QHfCqELo for ; Sun, 19 Jan 2020 09:11:52 +0100 (CET) Original-Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id EF3BD181B8179 for ; Sun, 19 Jan 2020 09:11:51 +0100 (CET) X-Virus-Scanned: amavisd-new at choca.pics Original-Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id 5lkGA8k9SIfY for ; Sun, 19 Jan 2020 09:11:51 +0100 (CET) Original-Received: from luz4 (57.139.120.78.rev.sfr.net [78.120.139.57]) by mail.choca.pics (Postfix) with ESMTPSA id B484F18191BBA for ; Sun, 19 Jan 2020 09:11:51 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 80.67.172.235 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:244363 Archived-At: Hi, I'm trying to write a general-purpose linting engine for Emacs Lisp. It currently uses a generator which repeatedly calls `(read buffer)` and yields the result. It also uses a generator to iterate over the sexps of a sexp, recursively. Here is the code: https://gitlab.com/lintel/lintel/blob/2c98a02b17e34140f576e0bf2a9a7c47920dc1ce/lintel.el#L283 This is not enough though as I want comments and line/column positions in the yielded values. Is there anything I could use from Emacs core that would make my life easier? I thought about using `parse-partial-sexp` and `syntax-ppss` but don't know which iteration strategy to use to get information on the whole buffer. I could also use `forward-sexp` and check for the presence of a comment at point each time this function returns. Any piece of advice would be appreciated. Please keep me in CC when answering. Thank you. -- Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill