aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/interp/lexing.boot16
-rw-r--r--src/interp/macros.lisp21
-rw-r--r--src/interp/preparse.lisp4
4 files changed, 25 insertions, 22 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index fdf8f767..f900aac6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2012-05-06 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/lexing.boot (indentationLocation): New.
+ * interp/macros.lisp (expand-tabs): Use it in lieu of NDENT-POS.
+ * interp/preparse.lisp (PREPARSE1): Likewise.
+
+2012-05-06 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/Makefile.in (OBJS): Include io.$(FASLEXT).
(io.$(FASLEXT)): New rule.
* interp/io.boot: New.
diff --git a/src/interp/lexing.boot b/src/interp/lexing.boot
index 4b357918..36b54fd5 100644
--- a/src/interp/lexing.boot
+++ b/src/interp/lexing.boot
@@ -44,6 +44,22 @@ module lexing where
matchString: %String -> %Maybe %Short
matchAdvanceString: %String -> %Maybe %Short
matchAdvanceKeyword: %Symbol -> %Thing
+ indentationLocation: %String -> %Maybe %Short
+
+--%
+
+++ Return the logical indentation position in the `line', after
+++ expansion of leading vertical tab characters.
+indentationLocation line ==
+ loc := 0
+ n := #line
+ for i in 0.. repeat
+ i >= n => return nil
+ spaceChar? line.i => loc := loc + 1
+ tabChar? line.i => loc := 8 * (loc quo 8 + 1)
+ return loc
+
+--%
--%
--% Line abstract datatype
diff --git a/src/interp/macros.lisp b/src/interp/macros.lisp
index 227533d5..c11951cb 100644
--- a/src/interp/macros.lisp
+++ b/src/interp/macros.lisp
@@ -475,29 +475,10 @@ terminals and empty or at-end files. In Common Lisp, we must assume record size
(terpri stream)
(finish-output stream)))
-;; moved here from preparse.lisp
-
-(defun NEXT-TAB-LOC (i) (* (1+ (truncate i 8)) 8))
-
-(defun INDENT-POS (STR)
- (do ((i 0 (1+ i))
- (pos 0))
- ((>= i (length str)) nil)
- (case (char str i)
- (#\space (incf pos))
- (#\tab (setq pos (next-tab-loc pos)))
- (otherwise (return pos)))))
-
-;;(defun expand-tabs (str)
-;; (let ((bpos (nonblankloc str))
-;; (tpos (indent-pos str)))
-;; (if (eql bpos tpos) str
-;; (concatenate 'string (make-string tpos :initial-element #\space)
-;; (subseq str bpos)))))
(defun expand-tabs (str)
(if (and (stringp str) (> (length str) 0))
(let ((bpos (nonblankloc str))
- (tpos (indent-pos str)))
+ (tpos (|indentationLocation| str)))
(setq str
(if (eql bpos tpos)
str
diff --git a/src/interp/preparse.lisp b/src/interp/preparse.lisp
index 0fd7bc3a..120656b1 100644
--- a/src/interp/preparse.lisp
+++ b/src/interp/preparse.lisp
@@ -133,7 +133,7 @@
(INSTRING)
((= N COMSYM) (setq A (subseq A 0 N)) (GO NOCOMS)) ; discard trailing comment
((= N NCOMSYM)
- (setq SLOC (INDENT-POS A))
+ (setq SLOC (|indentationLocation| A))
(COND
((= SLOC N)
(COND ((AND NCOMBLOCK (NOT (= N (CAR NCOMBLOCK))))
@@ -150,7 +150,7 @@
((= N CPARSYM) (setq PCOUNT (1- PCOUNT))))
(setq I (1+ N))
(GO STRLOOP)
- NOCOMS (setq SLOC (INDENT-POS A))
+ NOCOMS (setq SLOC (|indentationLocation| A))
(setq A (DROPTRAILINGBLANKS A))
(cond ((NULL SLOC) (setq SLOC PSLOC) (GO READLOOP)))
(cond ((EQ (ELT A (MAXINDEX A)) #\_)