aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/fnewmeta.lisp4
-rw-r--r--src/interp/lexing.boot12
-rw-r--r--src/interp/parsing.lisp16
3 files changed, 18 insertions, 14 deletions
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