aboutsummaryrefslogtreecommitdiff
path: root/src/interp/spad-parser.boot
diff options
context:
space:
mode:
Diffstat (limited to 'src/interp/spad-parser.boot')
-rw-r--r--src/interp/spad-parser.boot41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/interp/spad-parser.boot b/src/interp/spad-parser.boot
index 57229713..454b7a25 100644
--- a/src/interp/spad-parser.boot
+++ b/src/interp/spad-parser.boot
@@ -85,6 +85,47 @@ stringPrefix?(s1,s2) ==
n1 > #s2 => false
and/[s1.i = s2.i for i in 0..(n1-1)]
+skipIfBlock st ==
+ [n,:line] := z := preparseReadLine1 st
+ not string? line => z
+ #line = 0 => skipIfBlock st
+ line.0 = char ")" =>
+ stringPrefix?('")if",line) =>
+ EVAL string2BootTree storeBlanks!(line,2) => preparseReadLine st
+ skipIfBlock st
+ stringPrefix?('")elseif",line) =>
+ EVAL string2BootTree storeBlanks!(line,7) => preparseReadLine st
+ skipIfBlock st
+ stringPrefix?('")else",line) or stringPrefix?('")endif",line) =>
+ preparseReadLine st
+ stringPrefix?('")fin",line) => [n]
+ skipIfBlock st
+ skipIfBlock st
+
+skipToEndif st ==
+ [n,:line] := z := preparseReadLine1 st
+ not string? line => z
+ stringPrefix?(line,'")endif") => preparseReadLine st
+ stringPrefix?(line,'")fin") => [n]
+ skipToEndif st
+
+
+preparseReadLine st ==
+ [n,:line] := z := preparseReadLine1 st
+ not string? line or #line = 0 => z
+ line.0 = char ")" =>
+ stringPrefix?('")if",line) =>
+ EVAL string2BootTree storeBlanks!(line,3) => preparseReadLine st
+ skipIfBlock st
+ stringPrefix?('")elseif",line) or stringPrefix?('")else",line) =>
+ skipToEndif st
+ stringPrefix?('")endif",line) => preparseReadLine st
+ stringPrefix?('")fin",line) =>
+ SETQ(_*EOF_*,true)
+ [n]
+ z
+ z
+
--%
macro compulsorySyntax s ==
s or SPAD__SYNTAX__ERROR()