aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2012-05-11 05:05:57 +0000
committerdos-reis <gdr@axiomatics.org>2012-05-11 05:05:57 +0000
commit3580316a6efb4e026e08543bd9eed9df16316bbe (patch)
tree0ef803c0bb9539201f094ce802c6d45cfc8d8e68
parent233928c5bd284cd18a2b3eaa3e9774c145ae9c16 (diff)
downloadopen-axiom-3580316a6efb4e026e08543bd9eed9df16316bbe.tar.gz
* interp/preparse.lisp (preparseReadLine1): Move to spad-parser.boot.
-rw-r--r--src/ChangeLog4
-rw-r--r--src/interp/preparse.lisp31
-rw-r--r--src/interp/spad-parser.boot16
3 files changed, 24 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4c04d2fd..02454e9d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-11 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/preparse.lisp (preparseReadLine1): Move to spad-parser.boot.
+
2012-05-10 Igor Pashev <pashev.igor@gmail.com>
* hyper/initx.c: Fixed spelling errors.
diff --git a/src/interp/preparse.lisp b/src/interp/preparse.lisp
index 0d9e7ff1..6adf49c6 100644
--- a/src/interp/preparse.lisp
+++ b/src/interp/preparse.lisp
@@ -66,7 +66,7 @@
(defparameter $INDEX 0 "File line number of most recently read line.")
(defparameter |$preparseLastLine| () "Most recently read line.")
(defparameter |$preparseReportIfTrue| NIL "Should we print listings?")
-(defparameter $LineList nil "Stack of preparsed lines.")
+(defparameter |$LineList| nil "Stack of preparsed lines.")
(defparameter |$EchoLineStack| nil "Stack of lines to list.")
(defparameter $IOIndex 0 "Number of latest terminal input line.")
@@ -75,13 +75,13 @@
(DEFPARAMETER LABLASOC NIL)
(defun Initialize-Preparse (strm)
- (setq $INDEX 0 $LineList nil |$EchoLineStack| nil)
+ (setq $INDEX 0 |$LineList| nil |$EchoLineStack| nil)
(setq |$preparseLastLine| (|readLine| strm)))
(defvar $skipme)
(defun |preparse1| (LineList)
- (PROG (($LINELIST LineList) |$EchoLineStack| NUM A I L PSLOC
+ (PROG ((|$LineList| LineList) |$EchoLineStack| NUM A I L PSLOC
INSTRING PCOUNT COMSYM STRSYM OPARSYM CPARSYM N NCOMSYM
(SLOC -1) (CONTINUE NIL) (PARENLEV 0) (NCOMBLOCK ())
(LINES ()) (LOCS ()) (NUMS ()) functor )
@@ -125,7 +125,7 @@
(SETQ NCOMBLOCK (CONS N (CONS A (IFCDR NCOMBLOCK))))
(SETQ A ""))
('T (PUSH (STRCONC (|makeString| N #\Space)
- (SUBSTRING A N ())) $LINELIST)
+ (SUBSTRING A N ())) |$LineList|)
(SETQ $INDEX (1- $INDEX))
(SETQ A (SUBSEQ A 0 N))))
(GO NOCOMS))
@@ -177,29 +177,6 @@
(dolist (X L) (format t "~5d. ~a~%" (car x) (cdr x)))
(format t "~%"))))
-(DEFUN |preparseReadLine1| (X)
- (PROG (LINE IND)
- (SETQ LINE (if $LINELIST
- (pop $LINELIST)
- (|expandLeadingTabs| (|readLine| in-stream))))
- (setq |$preparseLastLine| LINE)
- (and (stringp line) (incf $INDEX))
- (COND
- ( (NOT (STRINGP LINE))
- (RETURN (LIST $INDEX)) ) )
- (SETQ LINE (|trimTrailingBlank| LINE))
- (PUSH (COPY-SEQ LINE) |$EchoLineStack|)
- ;; next line must evaluate $INDEX before recursive call
- (RETURN
- (CONS
- $INDEX
- (COND
- ( (AND (> (SETQ IND (|maxIndex| LINE)) -1) (char= (ELT LINE IND) #\_))
- (setq |$preparseLastLine|
- (STRCONC (SUBSTRING LINE 0 IND) (CDR (|preparseReadLine1| X))) ))
- ( 'T
- LINE ) ))) ) )
-
(defun PARSEPILES (LOCS LINES)
"Add parens and semis to lines to aid parsing."
(mapl #'add-parens-and-semis-to-line
diff --git a/src/interp/spad-parser.boot b/src/interp/spad-parser.boot
index e9e6b6b5..3076f91c 100644
--- a/src/interp/spad-parser.boot
+++ b/src/interp/spad-parser.boot
@@ -139,6 +139,22 @@ preparseReadLine x ==
z
z
+preparseReadLine1 x ==
+ if $LineList then
+ [line,:$LineList] := $LineList
+ else
+ line := expandLeadingTabs readLine IN_-STREAM
+ $preparseLastLine := line
+ not string? line => [$INDEX]
+ $INDEX := $INDEX + 1
+ line := trimTrailingBlank line
+ $EchoLineStack := [copyString line,:$EchoLineStack]
+ n := $INDEX
+ if #line > 0 and line.maxIndex(line) = char "__" then
+ line := strconc(subString(line,0,maxIndex line),rest preparseReadLine1 x)
+ $preparseLastLine := line
+ [n,:line]
+
preparseEcho lines ==
if $Echo then
for x in reverse lines repeat