diff options
Diffstat (limited to 'src/boot/scanner.boot')
-rw-r--r-- | src/boot/scanner.boot | 101 |
1 files changed, 36 insertions, 65 deletions
diff --git a/src/boot/scanner.boot b/src/boot/scanner.boot index 96dd03f6..3b521975 100644 --- a/src/boot/scanner.boot +++ b/src/boot/scanner.boot @@ -38,26 +38,7 @@ import includer namespace BOOTTRAN module scanner -shoeSPACE == QENUM('" ", 0) - -shoeESCAPE == QENUM('"__ ", 0) -shoeLispESCAPE := QENUM('"! ", 0) - -shoeSTRING_CHAR == QENUM('"_" ", 0) - -shoePLUSCOMMENT == QENUM('"+ ", 0) - -shoeMINUSCOMMENT == QENUM('"- ", 0) - -shoeDOT == QENUM('". ", 0) - -shoeEXPONENT1 == QENUM('"E ", 0) - -shoeEXPONENT2 == QENUM('"e ", 0) - -shoeCLOSEPAREN == QENUM('") ", 0) - -shoeTAB == 9 +shoeTAB == abstractChar 9 -- converts X to double-float. double x == @@ -107,7 +88,7 @@ shoeNextLine(s)== $n:=STRPOSL('" ",$ln,0,true) $sz :=# $ln $n = nil => true - QENUM($ln,$n)=shoeTAB => + stringChar($ln,$n) = shoeTAB => a:=MAKE_-FULL_-CVEC (7-REM($n,8) ,'" ") $ln.$n := char " " $ln := strconc(a,$ln) @@ -125,8 +106,7 @@ shoeLineToks(s)== $linepos:local:=s not shoeNextLine s => [nil,:nil] $n = nil => shoeLineToks $r - fst:=QENUM($ln,0) - EQL(fst,shoeCLOSEPAREN)=> + stringChar($ln,0) = char ")" => command:=shoeLine? $ln=> dq:=dqUnit shoeConstructToken ($ln,$linepos,shoeLeafLine command,0) @@ -145,7 +125,7 @@ shoeLineToks(s)== shoeLispToken(s,string)== string:= - # string=0 or QENUM(string,0) = QENUM('";",0) => '"" + #string = 0 or stringChar(string,0) = char ";" => '"" string ln:=$ln linepos:=$linepos @@ -157,11 +137,10 @@ shoeAccumulateLines(s,string)== not shoeNextLine s => [s,:string] $n = nil => shoeAccumulateLines($r,string) # $ln=0 => shoeAccumulateLines($r,string) - fst:=QENUM($ln,0) - EQL(fst,shoeCLOSEPAREN)=> + stringChar($ln,0) = char ")" => command:=shoeLisp? $ln command and #command>0 => - EQL(QENUM(command,0),QENUM('";",0))=> + stringChar(command,0) = char ";" => shoeAccumulateLines($r,string) a:=STRPOS('";",command,0,nil) a=> @@ -176,10 +155,9 @@ shoeCloser t == shoeKeyWord t in '(CPAREN CBRACK) shoeToken () == - ln:=$ln - c:=QENUM($ln,$n) - linepos:=$linepos - n:=$n + ln := $ln + linepos := $linepos + n := $n ch := stringChar($ln,$n) b:= shoeStartsComment() => @@ -188,16 +166,16 @@ shoeToken () == shoeStartsNegComment() => shoeNegComment() [] - c=shoeLispESCAPE => shoeLispEscape() - shoePunctuation c => shoePunct() + ch = char "!" => shoeLispEscape() + shoePunctuation codePoint ch => shoePunct() shoeStartsId ch => shoeWord(false) - c=shoeSPACE => + ch = char " " => shoeSpace() [] - c = shoeSTRING_CHAR => shoeString() - shoeDigit ch => shoeNumber() - c=shoeESCAPE => shoeEscape() - c=shoeTAB => + ch = char "_"" => shoeString() + digit? ch => shoeNumber() + ch = char "__" => shoeEscape() + ch = shoeTAB => $n:=$n+1 [] shoeError() @@ -282,19 +260,19 @@ shoeEsc()== shoeStartsComment()== $n < $sz => - QENUM($ln,$n) = shoePLUSCOMMENT => + stringChar($ln,$n) = char "+" => www:=$n+1 www >= $sz => false - QENUM($ln,www) = shoePLUSCOMMENT + stringChar($ln,www) = char "+" false false shoeStartsNegComment()== $n < $sz => - QENUM($ln,$n) = shoeMINUSCOMMENT => + stringChar($ln,$n) = char "-" => www:=$n+1 www >= $sz => false - QENUM($ln,www) = shoeMINUSCOMMENT + stringChar($ln,www) = char "-" false false @@ -321,7 +299,7 @@ shoeKeyTr w== shoeLeafKey w shoePossFloat (w)== - $n>=$sz or not shoeDigit stringChar($ln,$n) => shoeLeafKey w + $n>=$sz or not digit? stringChar($ln,$n) => shoeLeafKey w w := shoeInteger() shoeExponent('"0",w) @@ -365,24 +343,17 @@ shoeS()== shoeS() strconc(str,b) - - - shoeIdEnd(line,n)== while n<#line and shoeIdChar stringChar(line,n) repeat n := n+1 n - -shoeDigit x== - digit? x - shoeW(b)== n1 := $n $n := $n+1 l := $sz endid := shoeIdEnd($ln,$n) - endid=l or QENUM($ln,endid) ~= shoeESCAPE => + endid=l or stringChar($ln,endid) ~= char "__" => $n := endid [b,subString($ln,n1,endid-n1)] str := subString($ln,n1,endid-n1) @@ -409,9 +380,9 @@ shoeInteger() == shoeInteger1(zro) == n := $n l := $sz - while $n <l and shoeDigit stringChar($ln,$n) repeat + while $n <l and digit? stringChar($ln,$n) repeat $n := $n+1 - $n=l or QENUM($ln,$n)~=shoeESCAPE => + $n=l or stringChar($ln,$n) ~= char "__" => n = $n and zro => '"0" subString($ln,n,$n-n) str := subString($ln,n,$n-n) @@ -431,10 +402,10 @@ shoeIntValue(s) == shoeNumber() == a := shoeInteger() $n >= $sz => shoeLeafInteger a - $floatok and QENUM($ln,$n) = shoeDOT => + $floatok and stringChar($ln,$n) = char "." => n := $n $n := $n+1 - $n < $sz and QENUM($ln,$n)=shoeDOT => + $n < $sz and stringChar($ln,$n) = char "." => $n := n shoeLeafInteger a w := shoeInteger1(true) @@ -444,26 +415,26 @@ shoeNumber() == shoeExponent(a,w)== $n >= $sz => shoeLeafFloat(a,w,0) n := $n - c := QENUM($ln,$n) - c = shoeEXPONENT1 or c = shoeEXPONENT2 => + c := stringChar($ln,$n) + c = char "E" or c = char "e" => $n := $n+1 $n >= $sz => $n := n shoeLeafFloat(a,w,0) - shoeDigit stringChar($ln,$n) => + digit? stringChar($ln,$n) => e := shoeInteger() e := shoeIntValue e shoeLeafFloat(a,w,e) - c1 := QENUM($ln,$n) - c1 = shoePLUSCOMMENT or c1 = shoeMINUSCOMMENT => + c1 := stringChar($ln,$n) + c1 = char "+" or c1 = char "-" => $n := $n+1 $n >= $sz => $n := n shoeLeafFloat(a,w,0) - shoeDigit stringChar($ln,$n) => + digit? stringChar($ln,$n) => e := shoeInteger() e := shoeIntValue e - shoeLeafFloat(a,w,(c1=shoeMINUSCOMMENT => MINUS e; e)) + shoeLeafFloat(a,w,(c1 = char "-" => MINUS e; e)) $n := n shoeLeafFloat(a,w,0) -- FIXME: Missing alternative. @@ -474,7 +445,7 @@ shoeError()== $n:=$n+1 SoftShoeError([$linepos,:n], strconc( '"The character whose number is ", - toString QENUM($ln,n),'" is not a Boot character")) + toString codePoint stringChar($ln,n),'" is not a Boot character")) shoeLeafError stringChar($ln,n) shoeOrdToNum x== @@ -490,7 +461,7 @@ shoeMatch(l,i) == shoeSubStringMatch(l,shoeDict,i) shoeSubStringMatch (l,d,i)== - h := QENUM(l, i) + h := codePoint stringChar(l, i) u := d.h ll := #l done := false @@ -502,7 +473,7 @@ shoeSubStringMatch (l,d,i)== ls+i > ll => false eql := true for k in 1..ls-1 while eql repeat - eql := QENUM(s,k) = QENUM(l,k+i) + eql := stringChar(s,k) = stringChar(l,k+i) eql => s1:=s true |