aboutsummaryrefslogtreecommitdiff
path: root/src/interp/lexing.boot
diff options
context:
space:
mode:
Diffstat (limited to 'src/interp/lexing.boot')
-rw-r--r--src/interp/lexing.boot12
1 files changed, 12 insertions, 0 deletions
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.