aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/interp/fnewmeta.lisp4
-rw-r--r--src/interp/lexing.boot12
-rw-r--r--src/interp/parsing.lisp16
4 files changed, 25 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index bd27c57d..cc61e6b3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
2011-10-10 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/lexing.boot (matchString): New.
+ * interp/fnewmeta.lisp: Use it.
+ * interp/parsing.lisp: Likewise.
+ (MATCH-STRING): Remove.
+
+2011-10-10 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/metalex.lisp (DEFUN-PARSE-TOKEN): Remove.
Move remaining to parsing.lisp.
* interp/fnewmeta.lisp (PARSE-IntegerTok): Remove.
diff --git a/src/interp/fnewmeta.lisp b/src/interp/fnewmeta.lisp
index 62b1a34d..af2861f3 100644
--- a/src/interp/fnewmeta.lisp
+++ b/src/interp/fnewmeta.lisp
@@ -51,7 +51,7 @@
(MEMBER (|currentSymbol|) '(\) END\_UNIT NIL)))
(DEFUN |PARSE-NewExpr| ()
- (OR (AND (MATCH-STRING ")") (ACTION (|processSynonyms|))
+ (OR (AND (|matchString| ")") (ACTION (|processSynonyms|))
(MUST (|PARSE-Command|)))
(AND (ACTION (SETQ DEFINITION_NAME (|currentSymbol|)))
(|PARSE-Statement|))))
@@ -779,7 +779,7 @@
(DEFUN |PARSE-AnyId| ()
(OR (|parseName|)
- (OR (AND (MATCH-STRING "$")
+ (OR (AND (|matchString| "$")
(|pushReduction| '|PARSE-AnyId| (|currentSymbol|))
(ACTION (|advanceToken|)))
(|parseToken| 'KEYWORD)
diff --git a/src/interp/lexing.boot b/src/interp/lexing.boot
index 992239e3..712b1927 100644
--- a/src/interp/lexing.boot
+++ b/src/interp/lexing.boot
@@ -372,6 +372,18 @@ ungetTokens() ==
coreError '"How many tokens do you think you have?"
+++ Returns length of X if X matches initial segment of IN-STREAM.
+++ Otherwise, return nil.
+matchString x ==
+ ungetTokens()
+ skipBlankChars()
+ not linePastEnd? $spadLine and currentChar() ~= nil =>
+ nx := #x
+ buf := lineBuffer $spadLine
+ idx := lineCurrentIndex $spadLine
+ nx + idx > #buf => nil
+ and/[stringChar(x,i) = stringChar(buf,idx + i) for i in 0..nx-1] and nx
+ nil
--%
--% Stack abstract datatype.
diff --git a/src/interp/parsing.lisp b/src/interp/parsing.lisp
index b8ca2142..1dd53dea 100644
--- a/src/interp/parsing.lisp
+++ b/src/interp/parsing.lisp
@@ -350,21 +350,13 @@ the stack, then stack a NIL. Return the value of prod."
; FUNCTIONS DEFINED IN THIS SECTION:
;
-; Match-String, Match-Advance-String
-
-(defun Match-String (x)
- "Returns length of X if X matches initial segment of inputstream."
- (|ungetTokens|) ; So we don't get out of synch with token stream
- (|skipBlankChars|)
- (if (and (not (|linePastEnd?| |$spadLine|)) (|currentChar|) )
- (initial-substring-p x
- (subseq (|lineBuffer| |$spadLine|) (|lineCurrentIndex| |$spadLine|)))))
+; Match-Advance-String
(defun Match-Advance-String (x)
- "Same as MATCH-STRING except if successful, advance inputstream past X."
+ "Same as matchString except if successful, advance inputstream past X."
(let ((y (if (>= (length (string x))
(length (string (|quoteIfString| (|currentToken|)))))
- (Match-String x)
+ (|matchString| x)
nil))) ; must match at least the current token
(if y (progn (incf (|lineCurrentIndex| |$spadLine|) y)
(if (not (|linePastEnd?| |$spadLine|))
@@ -425,7 +417,7 @@ the stack, then stack a NIL. Return the value of prod."
(defun termchr () "Is CHR a terminating character?"
(position (|currentChar|) " *,;<>()[]/\\"))
-(defun compfin () (or (match-string ")fin") (match-string ".FIN")))
+(defun compfin () (or (|matchString| ")fin") (|matchString| ".FIN")))
; 3 C. Constructing parsing procedures