summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès2013-03-18 00:08:29 +0100
committerLudovic Courtès2013-03-18 00:08:29 +0100
commited4906e2db1f3a89a10eae2db1c8bd8324acc82a (patch)
tree14fa57924464501eb605f518cf4114fbf6a1e3ab
parentbe7c4ea1e7f9e34582c77c21f7ab69b082f83100 (diff)
downloadskribilo-ed4906e2db1f3a89a10eae2db1c8bd8324acc82a.tar.gz
skribilo-ed4906e2db1f3a89a10eae2db1c8bd8324acc82a.tar.lz
skribilo-ed4906e2db1f3a89a10eae2db1c8bd8324acc82a.zip
Add `location->string'.
* src/guile/skribilo/location.scm (location->string): New procedure. * src/guile/skribilo/ast.scm (ast->file-location): Use it.
-rw-r--r--src/guile/skribilo/ast.scm7
-rw-r--r--src/guile/skribilo/location.scm12
2 files changed, 12 insertions, 7 deletions
diff --git a/src/guile/skribilo/ast.scm b/src/guile/skribilo/ast.scm
index 6b7fc26..1b0b47b 100644
--- a/src/guile/skribilo/ast.scm
+++ b/src/guile/skribilo/ast.scm
@@ -2,7 +2,7 @@
;;;
;;; Copyright 2003, 2004, 2009 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;; Copyright 2003, 2004 Manuel Serrano
-;;; Copyright 2005, 2006, 2007, 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright 2005, 2006, 2007, 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;;
;;;
;;; This file is part of Skribilo.
@@ -198,10 +198,7 @@
(define (ast->file-location ast)
- (let ((l (ast-loc ast)))
- (if (location? l)
- (format #f "~a:~a:" (location-file l) (location-line l))
- "")))
+ (location->string (ast-loc ast)))
(define-generic ast->string)
diff --git a/src/guile/skribilo/location.scm b/src/guile/skribilo/location.scm
index 2f9e627..fa88b18 100644
--- a/src/guile/skribilo/location.scm
+++ b/src/guile/skribilo/location.scm
@@ -1,7 +1,7 @@
;;; location.scm -- Skribilo source location.
;;; -*- coding: iso-8859-1 -*-
;;;
-;;; Copyright 2005, 2007, 2009, 2010, 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright 2005, 2007, 2009, 2010, 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;
;;;
@@ -27,7 +27,8 @@
:export (<location> location? ast-location
location-file location-line location-column
invocation-location
- source-properties->location))
+ source-properties->location
+ location->string))
;;; Author: Ludovic Courtès
;;;
@@ -113,4 +114,11 @@ etc."
:line (and line (+ line 1))
:column (and col (+ col 1))))))
+(define (location->string loc)
+ "Return a user-friendly representation of LOC."
+ (if (location? loc)
+ (format #f "~a:~a:~a:" (location-file loc) (location-line loc)
+ (location-column loc))
+ "<unknown-location>:"))
+
;;; location.scm ends here.