From 9edbca8047c527ce1036231a8616534e205822ba Mon Sep 17 00:00:00 2001 From: dos-reis Date: Wed, 9 May 2012 07:46:23 +0000 Subject: * interp/preparse.lisp (PREPARSE-ECHO): Move to spad-parser.boot. Rename to preparseEcho. * lisp/core.lisp.in (formatToStream): New. --- src/ChangeLog | 6 ++++++ src/interp/preparse.lisp | 29 ++++++++++++----------------- src/interp/spad-parser.boot | 6 ++++++ src/lisp/core.lisp.in | 4 ++++ 4 files changed, 28 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 8e1bee19..19e26749 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2012-05-09 Gabriel Dos Reis + + * interp/preparse.lisp (PREPARSE-ECHO): Move to spad-parser.boot. + Rename to preparseEcho. + * lisp/core.lisp.in (formatToStream): New. + 2012-05-08 Gabriel Dos Reis * boot/tokens.boot: Export char. Do not rename maxIndex. diff --git a/src/interp/preparse.lisp b/src/interp/preparse.lisp index 7eeb3cbd..487bef86 100644 --- a/src/interp/preparse.lisp +++ b/src/interp/preparse.lisp @@ -67,7 +67,7 @@ (defparameter $preparse-last-line () "Most recently read line.") (defparameter $preparseReportIfTrue NIL "Should we print listings?") (defparameter $LineList nil "Stack of preparsed lines.") -(defparameter $EchoLineStack nil "Stack of lines to list.") +(defparameter |$EchoLineStack| nil "Stack of lines to list.") (defparameter $IOIndex 0 "Number of latest terminal input line.") (DEFPARAMETER TOK NIL) @@ -75,7 +75,7 @@ (DEFPARAMETER LABLASOC NIL) (defun Initialize-Preparse (strm) - (setq $INDEX 0 $LineList nil $EchoLineStack nil) + (setq $INDEX 0 $LineList nil |$EchoLineStack| nil) (setq $preparse-last-line (|readLine| strm))) (defvar $skipme) @@ -98,13 +98,13 @@ U)))) (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 ) READLOOP (DCQ (NUM . A) (|preparseReadLine| LineList)) (cond ((|atEndOfUnit?| A) - (PREPARSE-ECHO LineList) + (|preparseEcho| LineList) (COND ((NULL LINES) (RETURN NIL)) (NCOMBLOCK (FINCOMBLOCK NIL NUMS LOCS NCOMBLOCK NIL))) @@ -112,7 +112,7 @@ (PARSEPILES (|reverse!| LOCS) (|reverse!| LINES)))))) (cond ((and (NULL LINES) (> (LENGTH A) 0) (EQ (CHAR A 0) #\) )) ; this is a command line, don't parse it - (PREPARSE-ECHO LineList) + (|preparseEcho| LineList) (setq $preparse-last-line nil) ;don't reread this line (SETQ LINE a) (CATCH 'SPAD_READER (|doSystemCommand| (subseq LINE 1))) @@ -169,7 +169,7 @@ (FINCOMBLOCK NUM NUMS LOCS NCOMBLOCK linelist)) (IF (NOT (|ioTerminal?| in-stream)) (setq $preparse-last-line - (|reverse!| $echolinestack))) + (|reverse!| |$EchoLineStack|))) (RETURN (|pairList| (|reverse!| NUMS) (PARSEPILES (|reverse!| LOCS) (|reverse!| LINES))))) (cond ((> PARENLEV 0) (PUSH NIL LOCS) (setq SLOC PSLOC) (GO REREAD))) @@ -177,7 +177,7 @@ (FINCOMBLOCK NUM NUMS LOCS NCOMBLOCK linelist) (setq NCOMBLOCK ()))) (PUSH SLOC LOCS) - REREAD (PREPARSE-ECHO LineList) + REREAD (|preparseEcho| LineList) (PUSH A LINES) (PUSH NUM NUMS) (setq PARENLEV (+ PARENLEV PCOUNT)) @@ -197,10 +197,10 @@ (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)) - (PREPARSE-ECHO linelist) - (SETQ $EchoLineStack (LIST NUM)))) + (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)) @@ -230,7 +230,7 @@ ( (NOT (STRINGP LINE)) (RETURN (LIST $INDEX)) ) ) (SETQ LINE (|trimTrailingBlank| LINE)) - (PUSH (COPY-SEQ LINE) $EchoLineStack) + (PUSH (COPY-SEQ LINE) |$EchoLineStack|) ;; next line must evaluate $INDEX before recursive call (RETURN (CONS @@ -242,11 +242,6 @@ ( 'T LINE ) ))) ) ) -(defun PREPARSE-ECHO (linelist) - (if |$Echo| (REPEAT (IN X (|reverse| $EchoLineStack)) - (format out-stream "~&;~A~%" X))) - (setq $EchoLineStack ())) - (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 d0ace700..69c8665e 100644 --- a/src/interp/spad-parser.boot +++ b/src/interp/spad-parser.boot @@ -124,6 +124,12 @@ preparseReadLine x == z z +preparseEcho lines == + if $Echo then + for x in reverse lines repeat + formatToStream(OUT_-STREAM,'"~&;~A~%",x) + $EchoLineStack := nil + --% macro compulsorySyntax s == s or SPAD__SYNTAX__ERROR() diff --git a/src/lisp/core.lisp.in b/src/lisp/core.lisp.in index 3fe31dae..ac989be8 100644 --- a/src/lisp/core.lisp.in +++ b/src/lisp/core.lisp.in @@ -113,6 +113,7 @@ "readExpr" "readIntegerIfCan" "formatToString" + "formatToStream" ;; compiler data structures "%Mode" @@ -588,6 +589,9 @@ (defmacro |formatToString| (&rest args) `(format nil ,@args)) +(defmacro |formatToStream| (&rest x) + `(format ,@x)) + ;; ;; -*- OpenAxiom filesystem -*- ;; -- cgit v1.2.3