diff options
-rw-r--r-- | src/guile/skribilo/ast.scm | 7 | ||||
-rw-r--r-- | src/guile/skribilo/location.scm | 12 |
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. |