From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan Nieuwenhuizen Newsgroups: gmane.lisp.guile.devel Subject: [PATCH 2/2] LALR-parser: transparent source locations using source-proprerties. Date: Sat, 2 Aug 2014 09:58:31 +0200 Message-ID: <1406966311-19014-3-git-send-email-janneke@gnu.org> References: <1406966311-19014-1-git-send-email-janneke@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1406966396 7186 80.91.229.3 (2 Aug 2014 07:59:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Aug 2014 07:59:56 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Aug 02 09:59:49 2014 Return-path: Envelope-to: guile-devel@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 1XDUEG-000205-2g for guile-devel@m.gmane.org; Sat, 02 Aug 2014 09:59:48 +0200 Original-Received: from localhost ([::1]:43331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDUEF-0000kE-OT for guile-devel@m.gmane.org; Sat, 02 Aug 2014 03:59:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDUE6-0000dv-3L for guile-devel@gnu.org; Sat, 02 Aug 2014 03:59:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XDUE1-0001m2-9R for guile-devel@gnu.org; Sat, 02 Aug 2014 03:59:38 -0400 Original-Received: from smtp-vbr8.xs4all.nl ([194.109.24.28]:4250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDUDu-0001ia-FI; Sat, 02 Aug 2014 03:59:26 -0400 Original-Received: from drakenvlieg.verum.local ([62.140.132.76]) (authenticated bits=0) by smtp-vbr8.xs4all.nl (8.13.8/8.13.8) with ESMTP id s727x1gl003341 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Sat, 2 Aug 2014 09:59:23 +0200 (CEST) (envelope-from janneke@gnu.org) X-Mailer: git-send-email 1.9.1 In-Reply-To: <1406966311-19014-1-git-send-email-janneke@gnu.org> X-Virus-Scanned: by XS4ALL Virus Scanner X-MIME-Autoconverted: from 8bit to quoted-printable by smtp-vbr8.xs4all.nl id s727x1gl003341 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 194.109.24.28 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17302 Archived-At: * module/system/base/lalr.upstream.scm (lalr-parser): Add token argument to push. (lr-driver): (___push): Transparently set source location from token using source-properties. --- module/system/base/lalr.upstream.scm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/module/system/base/lalr.upstream.scm b/module/system/base/la= lr.upstream.scm index b250c23..871c931 100755 --- a/module/system/base/lalr.upstream.scm +++ b/module/system/base/lalr.upstream.scm @@ -1609,7 +1609,10 @@ '())) ,(if (=3D nt 0) '$1 - `(___push ,n ,nt ,(cdr p) ,@(if (eq? driver-name 'lr-driver) '()= '(___sp))))))))) + `(___push ,n ,nt ,(cdr p) ,@(if (eq? driver-name 'lr-driver) '()= '(___sp))=20 + ,(if (eq? driver-name 'lr-driver) + `(vector-ref ___s= tack (1+ ___sp)) + `(list-ref ___sp = (1+ ___sp)))))))))) =20 gram/actions)))) =20 @@ -1825,7 +1828,11 @@ (if (>=3D ___sp (vector-length ___stack)) (___growstack))) =20 - (define (___push delta new-category lvalue) + (define (___push delta new-category lvalue tok) + (if (and (supports-source-properties? lvalue) + (not (source-property lvalue 'loc)) + (lexical-token? tok)) + (set-source-property! lvalue 'loc (lexical-token-source tok))) (set! ___sp (- ___sp (* delta 2))) (let* ((state (vector-ref ___stack ___sp)) (new-state (cdr (assoc new-category (vector-ref ___gtable sta= te))))) @@ -2000,7 +2007,7 @@ (set! *parses* (cons parse *parses*))) =20 =20 - (define (push delta new-category lvalue stack) + (define (push delta new-category lvalue stack tok) (let* ((stack (drop stack (* delta 2))) (state (car stack)) (new-state (cdr (assv new-category (vector-ref ___gtable stat= e))))) --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.= nl =20