aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2012-05-21 06:52:01 +0000
committerdos-reis <gdr@axiomatics.org>2012-05-21 06:52:01 +0000
commit327b68f0e2086eef9fc755b9ffba76343839e4ee (patch)
treec56fa61224f5fb7c8d75b6cb21f40e0132c7ef39 /src/interp
parent9d71472ce9d0b0fe0f8ff927b1ecb653d9b9a850 (diff)
downloadopen-axiom-327b68f0e2086eef9fc755b9ffba76343839e4ee.tar.gz
* interp/spad-parser.boot (addParensAndSemisToLine): Drop 'drop',
avoiding awakening GCL bug and quadratic traversal of lines. (parsePiles): Simplify.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/spad-parser.boot28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/interp/spad-parser.boot b/src/interp/spad-parser.boot
index 2799d88f..e934e2b9 100644
--- a/src/interp/spad-parser.boot
+++ b/src/interp/spad-parser.boot
@@ -177,28 +177,26 @@ addParensAndSemisToLine(lines,locs) ==
sc := first locs -- first line column number
sc = nil or sc <= 0 => nil
count := 0 -- number of semicolons added
- i := 0 -- running local line number
+ z := lines
for x in tails rest lines for y in tails rest locs repeat
- i := i + 1
- nc := first y
- nc = nil => nil
- nc := abs nc
- nc < sc => leave nil
- nc = sc and (y.first := -nc) and not infixToken? first x =>
- z := drop(i - 1,lines)
- z.first := addClose(first z,char ";")
- count := count + 1
+ do
+ nc := first y
+ nc = nil => nil
+ nc := abs nc
+ nc < sc => leave nil
+ nc = sc and (y.first := -nc) and not infixToken? first x =>
+ z.first := addClose(first z,char ";")
+ count := count + 1
+ z := rest z
count > 0 =>
first(lines).(firstNonblankCharPosition first lines - 1) := char "("
- lines := drop(i - 1,lines)
- lines.first := addClose(first lines,char ")")
+ z.first := addClose(first z,char ")")
nil
++ Add parens and semis to lines to aid parsing.
parsePiles(locs,lines) ==
- for x in tails append!(lines,['" "])
- for y in tails append!(locs,[nil]) repeat
- addParensAndSemisToLine(x,y)
+ for x in tails lines for y in tails locs repeat
+ addParensAndSemisToLine(x,y)
lines
parsePrint l ==