aboutsummaryrefslogtreecommitdiff
path: root/src/guile/skribilo/types.scm
diff options
context:
space:
mode:
Diffstat (limited to 'src/guile/skribilo/types.scm')
-rw-r--r--src/guile/skribilo/types.scm12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/guile/skribilo/types.scm b/src/guile/skribilo/types.scm
index 8d51c8c..4b3729c 100644
--- a/src/guile/skribilo/types.scm
+++ b/src/guile/skribilo/types.scm
@@ -45,6 +45,7 @@
document-options document-end
<language> language?
<location> location? ast-location
+ location-file location-line location-pos
*node-table*)
:use-module (oop goops))
@@ -65,6 +66,15 @@
(parent :accessor ast-parent :init-keyword :parent :init-value 'unspecified)
(loc :init-value #f))
+(define-method (initialize (ast <ast>) . args)
+ (next-method)
+ (let ((file (port-filename (current-input-port)))
+ (line (port-line (current-input-port)))
+ (column (port-column (current-input-port))))
+ (slot-set! ast 'loc
+ (make <location>
+ :file file :line line :pos (* line column)))))
+
(define (ast? obj) (is-a? obj <ast>))
(define (ast-loc obj) (slot-ref obj 'loc))
(define (ast-loc-set! obj v) (slot-set! obj 'loc v))
@@ -313,5 +323,5 @@
(> lenf len))
(substring fname len (+ 1 (string-length fname)))
fname)))
- (format "~a, line ~a" file line))
+ (format #f "~a, line ~a" file line))
"no source location")))