Commit d59b678e authored by John van Groningen's avatar John van Groningen
Browse files

remove preprocessor for Clean 1.3 code

parent 483abbc0
......@@ -1253,8 +1253,7 @@ ReadNormalChar {inp_stream = OldLine i line stream,inp_pos,inp_tabsize,inp_filen
)
= ReadNormalChar {inp_filename=inp_filename,inp_tabsize=inp_tabsize,inp_pos=inp_pos,inp_stream = stream}
ReadNormalChar {inp_stream = InFile file, inp_pos, inp_tabsize, inp_filename}
// MW8 was: #! (s, file) = freadline file
#! (s, file) = (SwitchPreprocessor freadPreprocessedLine freadline) file
#! (s, file) = freadline file
| size s==0
# c = NewLineChar
// pos = NextPos c inp_pos inp_tabsize
......@@ -1296,8 +1295,7 @@ ReadChar {inp_stream = OldLine i line stream,inp_pos,inp_tabsize,inp_filename}
inp_stream = stream}
//ReadChar input=:{inp_stream = InFile file, inp_pos, inp_tabsize}
ReadChar {inp_stream = InFile file, inp_pos, inp_tabsize, inp_filename}
// MW8 was: #! (s, file) = freadline file
#! (s, file) = (SwitchPreprocessor freadPreprocessedLine freadline) file
#! (s, file) = freadline file
| size s==0
# c = NewLineChar
pos = NextPos c inp_pos inp_tabsize
......@@ -1326,8 +1324,7 @@ ReadLine input=:{inp_stream = OldLine i line oldfile, inp_pos}
ReadLine input=:{inp_stream = InFile infile,inp_pos}
# (eof, file) = fend infile
| eof = ("", {input & inp_stream = InFile file})
//MW8 was # (l, file ) = freadline file
# (l, file ) = (SwitchPreprocessor freadPreprocessedLine freadline) file
# (l, file ) = freadline file
= (l, {input & inp_stream = InFile file, inp_pos = NextPos CRChar inp_pos 0})
ReadLine input = ("", input)
......@@ -1836,39 +1833,3 @@ where
(-->>) val _ :== val
//(-->>) val message :== val ---> ("Scanner",message)
// MW8..
//--------------------//
//--- Preprocessor ---//
//--------------------//
freadPreprocessedLine :: !*File -> (!.{#Char},!*File)
freadPreprocessedLine file
#! (line, file) = freadline file
| begins_with "/*2.0" line
= (replace_beginning_with "/***/" line, file)
| begins_with "0.2*/" line
= (replace_beginning_with "/***/" line, file)
| begins_with "//1.3" line
= (replace_beginning_with "/*1.3" line, file)
| begins_with "//3.1" line
= (replace_beginning_with "3.1*/" line, file)
= (line, file)
where
begins_with :: !String !String -> Bool
begins_with pattern line
# size_pattern = size pattern
| size line<size_pattern
= False
= loop pattern line (size_pattern-1)
loop :: !String !String !Int -> Bool
loop pattern line i
| i<0
= True
| line.[i]<>pattern.[i]
= False
= loop pattern line (i-1)
replace_beginning_with :: !String !*String -> .String
replace_beginning_with replacement string
= { string & [i] = replacement.[i] \\ i<-[0..size replacement-1] }
// ..MW8
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment