aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2012-05-09 09:07:08 +0000
committerdos-reis <gdr@axiomatics.org>2012-05-09 09:07:08 +0000
commitdd3eae6e56d4dfb21a893e57fe3f1cb002788328 (patch)
treed1c73c06b2557ab0c6d052cbabe2ec4f3b238a00
parent9edbca8047c527ce1036231a8616534e205822ba (diff)
downloadopen-axiom-dd3eae6e56d4dfb21a893e57fe3f1cb002788328.tar.gz
* interp/preparse.lisp (FINCOMBLOCK): Move to spad-parser.boot.
Rename to findCommentBlock.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/interp/preparse.lisp33
-rw-r--r--src/interp/spad-parser.boot15
3 files changed, 24 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 19e26749..290710c5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2012-05-09 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/preparse.lisp (FINCOMBLOCK): Move to spad-parser.boot.
+ Rename to findCommentBlock.
+
+2012-05-09 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/preparse.lisp (PREPARSE-ECHO): Move to spad-parser.boot.
Rename to preparseEcho.
* lisp/core.lisp.in (formatToStream): New.
diff --git a/src/interp/preparse.lisp b/src/interp/preparse.lisp
index 487bef86..ea7b12cf 100644
--- a/src/interp/preparse.lisp
+++ b/src/interp/preparse.lisp
@@ -107,7 +107,7 @@
(|preparseEcho| LineList)
(COND ((NULL LINES) (RETURN NIL))
(NCOMBLOCK
- (FINCOMBLOCK NIL NUMS LOCS NCOMBLOCK NIL)))
+ (|findCommentBlock| NIL NUMS LOCS NCOMBLOCK NIL)))
(RETURN (|pairList| (|reverse!| NUMS)
(PARSEPILES (|reverse!| LOCS) (|reverse!| LINES))))))
(cond ((and (NULL LINES) (> (LENGTH A) 0) (EQ (CHAR A 0) #\) ))
@@ -137,7 +137,7 @@
(COND
((= SLOC N)
(COND ((AND NCOMBLOCK (NOT (= N (CAR NCOMBLOCK))))
- (FINCOMBLOCK NUM NUMS LOCS NCOMBLOCK linelist)
+ (|findCommentBlock| NUM NUMS LOCS NCOMBLOCK linelist)
(SETQ NCOMBLOCK NIL)))
(SETQ NCOMBLOCK (CONS N (CONS A (IFCDR NCOMBLOCK))))
(SETQ A ""))
@@ -166,7 +166,7 @@
(progn (push functor |$constructorsSeen|) (setq $skipme nil))))
(when (and LINES (EQL SLOC 0))
(IF (AND NCOMBLOCK (NOT (ZEROP (CAR NCOMBLOCK))))
- (FINCOMBLOCK NUM NUMS LOCS NCOMBLOCK linelist))
+ (|findCommentBlock| NUM NUMS LOCS NCOMBLOCK linelist))
(IF (NOT (|ioTerminal?| in-stream))
(setq $preparse-last-line
(|reverse!| |$EchoLineStack|)))
@@ -174,7 +174,7 @@
(PARSEPILES (|reverse!| LOCS) (|reverse!| LINES)))))
(cond ((> PARENLEV 0) (PUSH NIL LOCS) (setq SLOC PSLOC) (GO REREAD)))
(COND (NCOMBLOCK
- (FINCOMBLOCK NUM NUMS LOCS NCOMBLOCK linelist)
+ (|findCommentBlock| NUM NUMS LOCS NCOMBLOCK linelist)
(setq NCOMBLOCK ())))
(PUSH SLOC LOCS)
REREAD (|preparseEcho| LineList)
@@ -188,31 +188,6 @@
(GO READLOOP)))
-;; NUM is the line number of the current line
-;; OLDNUMS is the list of line numbers of previous lines
-;; OLDLOCS is the list of previous indentation locations
-;; NCBLOCK is the current comment block
-(DEFUN FINCOMBLOCK (NUM OLDNUMS OLDLOCS NCBLOCK linelist)
- (PUSH
- (COND ((EQL (CAR NCBLOCK) 0) (CONS (1- NUM) (|reverse| (CDR NCBLOCK))))
- ;; comment for constructor itself paired with 1st line -1
- ('T
- (COND (|$EchoLineStack|
- (setq NUM (POP |$EchoLineStack|))
- (|preparseEcho| linelist)
- (SETQ |$EchoLineStack| (LIST NUM))))
- (cons
- ;; scan backwards for line to left of current
- (DO ((onums oldnums (cdr onums))
- (olocs oldlocs (cdr olocs))
- (sloc (car ncblock)))
- ((null onums) nil)
- (if (and (numberp (car olocs))
- (<= (car olocs) sloc))
- (return (car onums))))
- (|reverse| (CDR NCBLOCK)))))
- $COMBLOCKLIST))
-
(defun PARSEPRINT (L)
(if L
(progn (format t "~&~% *** PREPARSE ***~%~%")
diff --git a/src/interp/spad-parser.boot b/src/interp/spad-parser.boot
index 69c8665e..41297bfc 100644
--- a/src/interp/spad-parser.boot
+++ b/src/interp/spad-parser.boot
@@ -109,6 +109,21 @@ skipToEndif x ==
stringPrefix?(line,'")fin") => [n,:%nothing]
skipToEndif x
+++ `n' is the line number of the current line
+++ `oldnums' is the list of line numbers of previous lines
+++ `oldlocs' is the list of previous indentation locations
+++ `ncblock' is the current comment block
+findCommentBlock(n,oldnums,oldlocs,ncblock,lines) ==
+ x :=
+ [nc,:block] := ncblock
+ nc = 0 => [n - 1,:reverse block]
+ if $EchoLineStack then
+ [n,:$EchoLineStack] := $EchoLineStack
+ preparseEcho lines
+ $EchoLineStack := [n]
+ [or/[n for n in oldnums for l in oldlocs | integer? l and l <= nc],
+ :reverse block]
+ $COMBLOCKLIST := [x,:$COMBLOCKLIST]
preparseReadLine x ==
[n,:line] := z := preparseReadLine1 x