diff options
Diffstat (limited to 'src/boot')
-rw-r--r-- | src/boot/scanner.boot | 7 | ||||
-rw-r--r-- | src/boot/strap/scanner.clisp | 19 | ||||
-rw-r--r-- | src/boot/strap/utility.clisp | 11 | ||||
-rw-r--r-- | src/boot/utility.boot | 11 |
4 files changed, 35 insertions, 13 deletions
diff --git a/src/boot/scanner.boot b/src/boot/scanner.boot index e1f6bd0b..841d26db 100644 --- a/src/boot/scanner.boot +++ b/src/boot/scanner.boot @@ -135,8 +135,7 @@ shoeAccumulateLines(s,string)== command and #command>0 => stringChar(command,0) = char ";" => shoeAccumulateLines($r,string) - a:=STRPOS('";",command,0,nil) - a=> + a := charPosition(char ";",command,0) => shoeAccumulateLines($r, strconc(string,subString(command,0,a-1))) shoeAccumulateLines($r,strconc(string,command)) @@ -314,8 +313,8 @@ shoeS()== SoftShoeError([$linepos,:$n],'"quote added") '"" n := $n - strsym := STRPOS ('"_"",$ln,$n,nil) or $sz - escsym := STRPOS ('"__",$ln,$n,nil) or $sz + strsym := charPosition(char "_"",$ln,$n) or $sz + escsym := charPosition(char "__",$ln,$n) or $sz mn := MIN(strsym,escsym) mn=$sz => $n:=$sz diff --git a/src/boot/strap/scanner.clisp b/src/boot/strap/scanner.clisp index 2a01edc0..208c588a 100644 --- a/src/boot/strap/scanner.clisp +++ b/src/boot/strap/scanner.clisp @@ -131,13 +131,12 @@ (COND ((CHAR= (SCHAR |command| 0) (|char| '|;|)) (|shoeAccumulateLines| |$r| |string|)) - (T (SETQ |a| (STRPOS ";" |command| 0 NIL)) - (COND - (|a| (|shoeAccumulateLines| |$r| - (CONCAT |string| - (|subString| |command| 0 (- |a| 1))))) - (T (|shoeAccumulateLines| |$r| - (CONCAT |string| |command|))))))) + ((SETQ |a| (|charPosition| (|char| '|;|) |command| 0)) + (|shoeAccumulateLines| |$r| + (CONCAT |string| + (|subString| |command| 0 (- |a| 1))))) + (T (|shoeAccumulateLines| |$r| + (CONCAT |string| |command|))))) (T (|shoeAccumulateLines| |$r| |string|)))) (T (CONS |s| |string|)))))) @@ -347,8 +346,10 @@ ((NOT (< |$n| |$sz|)) (|SoftShoeError| (CONS |$linepos| |$n|) "quote added") "") (T (SETQ |n| |$n|) - (SETQ |strsym| (OR (STRPOS "\"" |$ln| |$n| NIL) |$sz|)) - (SETQ |escsym| (OR (STRPOS "_" |$ln| |$n| NIL) |$sz|)) + (SETQ |strsym| + (OR (|charPosition| (|char| '|"|) |$ln| |$n|) |$sz|)) + (SETQ |escsym| + (OR (|charPosition| (|char| '_) |$ln| |$n|) |$sz|)) (SETQ |mn| (MIN |strsym| |escsym|)) (COND ((EQUAL |mn| |$sz|) (SETQ |$n| |$sz|) diff --git a/src/boot/strap/utility.clisp b/src/boot/strap/utility.clisp index 02f52e9f..7bfc9387 100644 --- a/src/boot/strap/utility.clisp +++ b/src/boot/strap/utility.clisp @@ -302,3 +302,14 @@ ((OR (CHARACTERP |x|) (INTEGERP |x|)) (|removeScalar| |l| |x|)) (T (|removeValue| |l| |x|)))) +(DEFUN |charPosition| (|c| |s| |k|) + (PROG (|n|) + (RETURN + (PROGN + (SETQ |n| (LENGTH |s|)) + (LOOP + (COND + ((NOT (< |k| |n|)) (RETURN NIL)) + ((CHAR= (SCHAR |s| |k|) |c|) (RETURN |k|)) + (T (SETQ |k| (+ |k| 1))))))))) + diff --git a/src/boot/utility.boot b/src/boot/utility.boot index 0219af77..c5a6591f 100644 --- a/src/boot/utility.boot +++ b/src/boot/utility.boot @@ -248,3 +248,14 @@ remove(l,x) == symbol? x => removeSymbol(l,x) char? x or integer? x => removeScalar(l,x) removeValue(l,x) + +--% search + +++ Return the index of the character `c' in the string `s', if present. +++ Otherwise, return nil. +charPosition(c,s,k) == + n := # s + repeat + k >= n => return nil + stringChar(s,k) = c => return k + k := k + 1 |