# # function written by Frank Luebeck, 11/24/2004 # # GAP code which could be used instead of 'Read'. # It reads files with comments in form of '%COMMENT' and '%ENDCOMMENT' # in the following sense: # Any line beginning %COMMENT will be ignored as will all subsequent lines # up to and including a matching %ENDCOMMENT line (ie %COMMENT and # %ENDCOMMENT nest) # # You put the line below (with different path) in your .gaprc file. # # Read("/home/wdj/gapfiles/ReadNC.gap"); # ################################################################## StringFileUnCOMMENT := function(fname) local s, r, depth, z; s := SplitString(StringFile(fname), "\n", ""); r := []; depth := 0; for z in s do if depth > 0 then if Length(z) > 10 and z[1] = '%' and z{[1..11]} = "%ENDCOMMENT" then depth := depth - 1; elif Length(z) > 7 and z[1] = '%' and z{[1..8]} = "%COMMENT" then depth := depth + 1; fi; elif Length(z) < 8 or z[1] <> '%' then Add(r, z); elif z{[1..8]} = "%COMMENT" then depth := depth + 1; else Add(r, z); fi; od; Add(r, ""); return JoinStringsWithSeparator(r, "\n"); end; ReadNC := function(fname) Read(InputTextString(StringFileUnCOMMENT(fname))); return true; end;