aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog11
-rw-r--r--src/interp/parsing.lisp34
-rw-r--r--src/interp/spad-parser.boot29
-rw-r--r--src/interp/spad.lisp25
4 files changed, 43 insertions, 56 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6c61c356..80d9d77d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2012-05-21 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/spad.lisp (S-PROCESS): Rename to translateSpad and move
+ to spad-parser.boot.
+ * interp/parsing.lisp (MATCH-ADVANCE-SPECIAL): Remove.
+ (MATCH-SPECIAL): Likewise.
+ (MATCH-KEYWORD-NEXT): Likewise.
+ (INITIAL-SUBSTRING-P): Likewise.
+ (TERMCHR): Likewise.
+ (dollarTran): Simplify and move to spad-parser.boot.
+
2012-05-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/lexing.boot (getDecimalNumberToken): New.
diff --git a/src/interp/parsing.lisp b/src/interp/parsing.lisp
index 828de1db..a6a321e7 100644
--- a/src/interp/parsing.lisp
+++ b/src/interp/parsing.lisp
@@ -243,38 +243,10 @@ the stack, then stack a NIL. Return the value of prod."
(defun action (dothis) (or dothis t))
-; 3A. Manipulating the token stack and reading tokens
-
-; This section is broken up into 3 levels:
-;
-; (0) String grabbing: Match String, Match Advance String
-; (1) Token handling: Current Token, Next Token, Advance Token
-; (2) Character handling: Current Char, Next Char, Advance Char
-; (3) Line handling: Next Line, Print Next Line
-; (X) Random Stuff
-
-(defun match-advance-special (str)
- (and (|matchToken| (|currentToken|) 'special-char (character str))
- (action (|advanceToken|))))
-
-(defun match-special (str)
- (|matchToken| (|currentToken|) 'special-char (character str)))
-
-(defun match-keyword-next (str)
- (|matchToken| (|nextToken|) 'keyword (intern str)))
-
-(defun initial-substring-p (part whole)
- "Returns length of part if part matches initial segment of whole."
- (let ((x (string<= part whole)))
- (and x (= x (length part)) x)))
-
; 3B. Error handling
(defparameter line nil)
-(defun termchr () "Is CHR a terminating character?"
- (|findChar| (|currentChar|) " *,;<>()[]/\\"))
-
; 5. Routines for inspecting and resetting total I/O system state
;
; The package largely assumes that:
@@ -310,9 +282,3 @@ the stack, then stack a NIL. Return the value of prod."
(DIGITP (ELT S I)))))
(READ-FROM-STRING S t nil :start 1)
NIL))
-
-(defun |dollarTran| (dom rand)
- (let ((eltWord (if |$InteractiveMode| '|$elt| '|elt|)))
- (if (and (not (atom rand)) (cdr rand))
- (cons (list eltWord dom (car rand)) (cdr rand))
- (list eltWord dom rand))))
diff --git a/src/interp/spad-parser.boot b/src/interp/spad-parser.boot
index 3e821cda..2799d88f 100644
--- a/src/interp/spad-parser.boot
+++ b/src/interp/spad-parser.boot
@@ -420,6 +420,10 @@ parseCommand() ==
parseTokenOption() ==
matchAdvanceString '")" and compulsorySyntax PARSE_-TokenList()
+dollarTran(dom,x) ==
+ x is [.,:.] => [['elt,dom,first x],:rest x]
+ ['elt,dom,x]
+
parseQualification() ==
matchAdvanceString '"$" =>
compulsorySyntax parsePrimary1()
@@ -931,6 +935,31 @@ parseSpecialCommand() ==
--%
+translateSpad x ==
+ $Index: local := 0
+ _*PRETTY_-PRINT_*: local := true
+ $MACROASSOC: local := nil
+ $NEWSPAD: local := true
+ $currentFunction: local := nil
+ $topOp: local := nil
+ $semanticErrorStack: local := []
+ $warningStack: local := []
+ $returnMode: local := $EmptyMode
+ $leaveLevelStack: local := []
+ $insideFunctorIfTrue: local := false
+ $insideExpressionIfTrue: local := false
+ $insideCoerceInteractiveHardIfTrue: local := false
+ $insideWhereIfTrue: local := false
+ $insideCategoryIfTrue: local := false
+ $insideCapsuleFunctionIfTrue: local := false
+ $form: local := nil
+ $e: local := $EmptyEnvironment
+ $genSDVar: local := 0
+ $previousTime: local := TEMPUS_-FUGIT()
+ compileParseTree x
+
+--%
+
++ Given a pathname to a source file containing Spad code, returns
++ a list of (old) AST objects representing the toplevel expressions
++ in that file.
diff --git a/src/interp/spad.lisp b/src/interp/spad.lisp
index 51127730..cc25cde5 100644
--- a/src/interp/spad.lisp
+++ b/src/interp/spad.lisp
@@ -130,7 +130,7 @@
(let ((parseout (|popStack1|)) )
(when parseout
(let ((|$OutputStream| out-stream))
- (S-PROCESS parseout))
+ (|translateSpad| parseout))
(format out-stream "~&")))
;(IOClear in-stream out-stream)
))))
@@ -150,7 +150,7 @@
(|addBinding| '|$DomainsInScope| proplist
(|addBinding| '|$Information| NIL
(COPY-TREE |$InitialModemapFrame|))))
- (RETURN (PROGN (S-PROCESS X) NIL))))
+ (RETURN (PROGN (|translateSpad| X) NIL))))
;; NIL needed below since END\_UNIT is not generated by current parser
@@ -275,25 +275,6 @@
(defun \,max (x y) (max x y))
(defun \,min (x y) (min x y))
-(defun S-PROCESS (X)
- (let ((|$Index| 0)
- (*print-pretty* t)
- ($MACROASSOC ())
- ($NEWSPAD T)
- |$currentFunction|
- |$topOp|
- (|$semanticErrorStack| ())
- (|$warningStack| ())
- (|$returnMode| |$EmptyMode|)
- (|$leaveLevelStack| ())
- |$insideFunctorIfTrue| |$insideExpressionIfTrue|
- |$insideCoerceInteractiveHardIfTrue| |$insideWhereIfTrue|
- |$insideCategoryIfTrue| |$insideCapsuleFunctionIfTrue| |$form|
- (|$e| |$EmptyEnvironment|)
- (|$genSDVar| 0)
- (|$previousTime| (TEMPUS-FUGIT)))
- (|compileParseTree| X)))
-
(MAKEPROP 'END_UNIT 'KEY T)
(defun |process| (x)
@@ -301,7 +282,7 @@
(SETQ DEBUGMODE 'NO)
(SPAD_SYNTAX_ERROR)
(if |$InteractiveMode| (|spadThrow|))
- (S-PROCESS x))))
+ (|translateSpad| x))))
(defun INITIALIZE ()
(init-boot/spad-reader)