From ed4906e2db1f3a89a10eae2db1c8bd8324acc82a Mon Sep 17 00:00:00 2001
From: Ludovic Courtès
Date: Mon, 18 Mar 2013 00:08:29 +0100
Subject: Add `location->string'.

* src/guile/skribilo/location.scm (location->string): New procedure.
* src/guile/skribilo/ast.scm (ast->file-location): Use it.
---
 src/guile/skribilo/ast.scm      |  7 ++-----
 src/guile/skribilo/location.scm | 12 ++++++++++--
 2 files changed, 12 insertions(+), 7 deletions(-)

(limited to 'src/guile')

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.
-- 
cgit v1.2.3