aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2012-05-09 14:07:02 +0000
committerdos-reis <gdr@axiomatics.org>2012-05-09 14:07:02 +0000
commita898c07228fbff5c3aa8653a52276ca9d0514158 (patch)
tree54eeb3b7285afe2c218f383c134fe36c4db83ac2 /src
parentdd3eae6e56d4dfb21a893e57fe3f1cb002788328 (diff)
downloadopen-axiom-a898c07228fbff5c3aa8653a52276ca9d0514158.tar.gz
* interp/preparse.lisp (PREPARSE): Move to spad-parser.boot.
Rename as preparse.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/interp/lexing.boot2
-rw-r--r--src/interp/preparse.lisp37
-rw-r--r--src/interp/spad-parser.boot22
-rw-r--r--src/interp/spad.lisp2
5 files changed, 40 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 290710c5..56f10878 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,12 +1,17 @@
2012-05-09 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/preparse.lisp (PREPARSE): Move to spad-parser.boot.
+ Rename as preparse.
+
+2012-05-09 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/preparse.lisp (FINCOMBLOCK): Move to spad-parser.boot.
- Rename to findCommentBlock.
+ Rename as findCommentBlock.
2012-05-09 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/preparse.lisp (PREPARSE-ECHO): Move to spad-parser.boot.
- Rename to preparseEcho.
+ Rename as preparseEcho.
* lisp/core.lisp.in (formatToStream): New.
2012-05-08 Gabriel Dos Reis <gdr@cs.tamu.edu>
diff --git a/src/interp/lexing.boot b/src/interp/lexing.boot
index 4b357918..940f0e4d 100644
--- a/src/interp/lexing.boot
+++ b/src/interp/lexing.boot
@@ -110,7 +110,7 @@ lineAdvanceChar! l ==
++ Current input line
$spadLine := makeLine()
-++ List of lines returned from PREPARSE
+++ List of lines returned from preparse
$lineStack := nil
nextLine st ==
diff --git a/src/interp/preparse.lisp b/src/interp/preparse.lisp
index ea7b12cf..331aa3e3 100644
--- a/src/interp/preparse.lisp
+++ b/src/interp/preparse.lisp
@@ -32,7 +32,7 @@
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;; NAME: Pre-Parsing Code
-;; PURPOSE: BOOT lines are massaged by PREPARSE to make them easier to parse:
+;; PURPOSE: BOOT lines are massaged by preparse to make them easier to parse:
;; 1. Trailing -- comments are removed (this is already done, actually).
;; 2. Comments between { and } are removed.
;; 3. BOOT code is column-sensitive. Code which lines up columnarly is
@@ -64,8 +64,8 @@
; Global storage
(defparameter $INDEX 0 "File line number of most recently read line.")
-(defparameter $preparse-last-line () "Most recently read line.")
-(defparameter $preparseReportIfTrue NIL "Should we print listings?")
+(defparameter |$preparseLastLine| () "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 $IOIndex 0 "Number of latest terminal input line.")
@@ -76,28 +76,11 @@
(defun Initialize-Preparse (strm)
(setq $INDEX 0 $LineList nil |$EchoLineStack| nil)
- (setq $preparse-last-line (|readLine| strm)))
+ (setq |$preparseLastLine| (|readLine| strm)))
(defvar $skipme)
-(defun PREPARSE (Strm &aux (stack ()))
- (SETQ $COMBLOCKLIST NIL $skipme NIL)
- (when $preparse-last-line
- (if (consp $preparse-last-line)
- (setq stack $preparse-last-line)
- (push $preparse-last-line stack))
- (setq $INDEX (- $INDEX (length stack))))
- (let ((U (PREPARSE1 stack)))
- (if $skipme (preparse strm)
- (progn
- (if $preparseReportIfTrue (PARSEPRINT U))
- (setq |$headerDocumentation| NIL)
- (SETQ |$docList| NIL)
- (SETQ |$maxSignatureLineNumber| 0)
- (SETQ |$constructorLineNumber| (IFCAR (IFCAR U)))
- U))))
-
-(defun PREPARSE1 (LineList)
+(defun |preparse1| (LineList)
(PROG (($LINELIST LineList) |$EchoLineStack| NUM A I L PSLOC
INSTRING PCOUNT COMSYM STRSYM OPARSYM CPARSYM N NCOMSYM
(SLOC -1) (CONTINUE NIL) (PARENLEV 0) (NCOMBLOCK ())
@@ -113,7 +96,7 @@
(cond ((and (NULL LINES) (> (LENGTH A) 0) (EQ (CHAR A 0) #\) ))
; this is a command line, don't parse it
(|preparseEcho| LineList)
- (setq $preparse-last-line nil) ;don't reread this line
+ (setq |$preparseLastLine| nil) ;don't reread this line
(SETQ LINE a)
(CATCH 'SPAD_READER (|doSystemCommand| (subseq LINE 1)))
(GO READLOOP)))
@@ -168,7 +151,7 @@
(IF (AND NCOMBLOCK (NOT (ZEROP (CAR NCOMBLOCK))))
(|findCommentBlock| NUM NUMS LOCS NCOMBLOCK linelist))
(IF (NOT (|ioTerminal?| in-stream))
- (setq $preparse-last-line
+ (setq |$preparseLastLine|
(|reverse!| |$EchoLineStack|)))
(RETURN (|pairList| (|reverse!| NUMS)
(PARSEPILES (|reverse!| LOCS) (|reverse!| LINES)))))
@@ -182,7 +165,7 @@
(PUSH NUM NUMS)
(setq PARENLEV (+ PARENLEV PCOUNT))
(when (and (|ioTerminal?| in-stream) (not continue))
- (setq $preparse-last-line nil)
+ (setq |$preparseLastLine| nil)
(RETURN (|pairList| (|reverse!| NUMS)
(PARSEPILES (|reverse!| LOCS) (|reverse!| LINES)))))
@@ -199,7 +182,7 @@
(SETQ LINE (if $LINELIST
(pop $LINELIST)
(expand-tabs (|readLine| in-stream))))
- (setq $preparse-last-line LINE)
+ (setq |$preparseLastLine| LINE)
(and (stringp line) (incf $INDEX))
(COND
( (NOT (STRINGP LINE))
@@ -212,7 +195,7 @@
$INDEX
(COND
( (AND (> (SETQ IND (|maxIndex| LINE)) -1) (char= (ELT LINE IND) #\_))
- (setq $preparse-last-line
+ (setq |$preparseLastLine|
(STRCONC (SUBSTRING LINE 0 IND) (CDR (|preparseReadLine1| X))) ))
( 'T
LINE ) ))) ) )
diff --git a/src/interp/spad-parser.boot b/src/interp/spad-parser.boot
index 41297bfc..e9e6b6b5 100644
--- a/src/interp/spad-parser.boot
+++ b/src/interp/spad-parser.boot
@@ -145,6 +145,26 @@ preparseEcho lines ==
formatToStream(OUT_-STREAM,'"~&;~A~%",x)
$EchoLineStack := nil
+preparse st ==
+ $COMBLOCKLIST := nil
+ $SKIPME := false
+ stack :=
+ $preparseLastLine =>
+ $preparseLastLine is [.,:.] => $preparseLastLine
+ [$preparseLastLine]
+ nil
+ $INDEX := $INDEX - #stack
+ u := preparse1 stack
+ $SKIPME => preparse st
+ if $preparseReportIfTrue then
+ PARSEPRINT u
+ $headerDocumentation := nil
+ $docList := nil
+ $maxSignatureLineNumber := 0
+ $constructorLineNumber := IFCAR IFCAR u
+ u
+
+
--%
macro compulsorySyntax s ==
s or SPAD__SYNTAX__ERROR()
@@ -887,7 +907,7 @@ parseSpadFile sourceFile ==
-- gather parse trees for all toplevel expressions in sourceFile.
asts := []
while not eof? IN_-STREAM repeat
- $lineStack: local := PREPARSE IN_-STREAM
+ $lineStack: local := preparse IN_-STREAM
$lineStack = nil => leave nil -- explicit end of input
LINE: local := CDAR $lineStack
CATCH('SPAD__READER,parseNewExpr())
diff --git a/src/interp/spad.lisp b/src/interp/spad.lisp
index 5aec187c..aa1971a1 100644
--- a/src/interp/spad.lisp
+++ b/src/interp/spad.lisp
@@ -121,7 +121,7 @@
(if (|eof?| in-stream) (return nil))
(catch 'SPAD_READER
(progn
- (setq |$lineStack| (PREPARSE in-stream))
+ (setq |$lineStack| (|preparse| in-stream))
(when (null |$lineStack|)
(return nil))
(when |$lineStack|