[Aimmath-commit] AIM/WEB-INF/maple/aim Compile.mpl,1.2.2.2,1.2.2.3
Brought to you by:
gustav_delius,
npstrick
From: <gr...@us...> - 2003-07-13 15:02:18
|
Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim In directory sc8-pr-cvs1:/tmp/cvs-serv6454/aim Modified Files: Tag: develop_2_1 Compile.mpl Log Message: Fixed code dealing with i> or include> flags. There were a few problems: 1. `aim/Compile/Readlines` didn't call `aim/Compile/GetIncludes` for an i> or include> that was the first or last flag. 2. The arguments were in the wrong order when `aim/Compile/GetIncludes` was called. 3. The brackets weren't stripped off the lines compiled by `aim/Compile/Readlines` within a `aim/Compile/GetIncludes` call. 4. `aim/Compile/GetIncludes` did not expand EXAMPLES in a file name. To deal with 1. `aim/Compile/GetIncludes` needed to be called twice and so for the sake of elegance some code was moved to `aim/Compile/GetIncludes` and the flag also passed. In order to reflect the slight change in function `aim/Compile/GetIncludes` was renamed `aim/Compile/ExpandIncludes` - GG Index: Compile.mpl =================================================================== RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Compile.mpl,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -C2 -d -r1.2.2.2 -r1.2.2.3 *** Compile.mpl 10 Jul 2003 20:10:03 -0000 1.2.2.2 --- Compile.mpl 13 Jul 2003 15:02:14 -0000 1.2.2.3 *************** *** 1392,1396 **** ", proc(file::string,depth_::integer) ! local depth,filehandle,retseq,flag,line,i,l,f; if nargs < 2 then --- 1392,1396 ---- ", proc(file::string,depth_::integer) ! local depth,filehandle,retseq,flag,line,dir,i,l,f; if nargs < 2 then *************** *** 1405,1410 **** retseq := NULL; ! flag := NULL; line := ""; while true do --- 1405,1411 ---- retseq := NULL; ! flag := ""; line := ""; + dir := `Util/Dirname`(file); while true do *************** *** 1416,1459 **** l := `Util/Unixify`(l); f := `aim/Compile/FindFlag`(l); ! if (flag = NULL) then ! # this is the first non-ignored line ! if (nops(f) = 2) then ! flag := f[1]; ! line := f[2]; ! else ! ERROR( cat(sprintf("Read error in file %A\n",file), ! "The first line (apart from comments and blank lines) is:\n", ! sprintf("%A\n",l), ! "This does not start with a flag.\n")); ! fi; ! else # not the first non-ignored line. ! if (nops(f) = 2) then ! # We have a new flag. ! # If the previous flag was an include>, add the contents of ! # the indicated files to retseq. Otherwise, just add the ! # previous flag and associated text to retseq. ! if (flag = "include>") then ! retseq := ! retseq, ! `aim/Compile/GetIncludes`(line,depth,`Util/Dirname`(file)); ! else ! retseq := retseq,[flag,line]; ! fi; ! ! flag := f[1]; ! line := f[2]; ! else ! # This is a continuation line, attached to a flag that we read ! # earlier. ! line := cat(line,"\n",f[1]); ! fi; # matches if (nops(f) = 2) then ... else ... ! fi; # matches if (flag = NULL) then ... else ... fi; # matches if (line is blank or comment) then ... else ... od; ! if ( flag <> NULL ) then ! retseq := retseq,[flag,line]; ! fi; fclose(filehandle); --- 1417,1442 ---- l := `Util/Unixify`(l); f := `aim/Compile/FindFlag`(l); ! if (nops(f) = 2) then ! # We have a new flag. First deal with the previous flag, if there ! # was one. ! retseq := retseq, `aim/Compile/ExpandIncludes`(flag,line,dir,depth); ! flag := f[1]; ! line := f[2]; ! elif (flag <> "") then ! # f[1] is a continuation line, attached to a flag that we read ! # earlier. ! line := cat(line,"\n",f[1]); ! else ! # f[1] contains the first non-ignored line, but it doesn't have a flag ! ERROR( cat(sprintf("Read error in file %A\n",file), ! "The first line (apart from comments and blank lines) is:\n", ! sprintf("%A\n",l), ! "This does not start with a flag.\n")); ! fi; # matches if (nops(f) = 2) then ... elif ... else ... fi; # matches if (line is blank or comment) then ... else ... od; ! retseq := retseq, `aim/Compile/ExpandIncludes`(flag,line,dir,depth); fclose(filehandle); *************** *** 1492,1511 **** `Package/Assign`( ! `aim/Compile/GetIncludes`, ! "This interprets @line@ as a list of filenames (possibly with wildcards). It applies #`aim/Compile/ReadLines`# to each of the relevant files, ! concatenates the resulting sequences, and returns the result. ", ! proc(line::string,dir::string,depth_::integer) ! local depth,filelist,expandedfilelist,filespec,directorypart, matchingfiles,newlines,includefile; ! if nargs < 2 then ! depth := 0; ! else ! depth := depth_; ! fi; ! ! if (depth > 10) then ERROR(__("File inclusion nested more than 10 levels deep.")); fi; --- 1475,1497 ---- `Package/Assign`( ! `aim/Compile/ExpandIncludes`, ! "If @flag@ is empty there is nothing to do (NULL is returned); this is ! the case when #`aim/Compile/ReadLines`# is first called for a file. ! If @flag@ is not \"include>\" nothing needs to be expanded and so ! [@flag@, @line@] is returned. ! Otherwise, @line@ as a list of filenames (possibly with wildcards). It applies #`aim/Compile/ReadLines`# to each of the relevant files, ! concatenates the resulting sequences of flag-line lists, and ! returns the result. ", ! proc(flag::string,line::string,dir::string,depth::integer) ! local filelist,expandedfilelist,filespec,directorypart, matchingfiles,newlines,includefile; ! if (flag = "") then ! RETURN(NULL); ! elif (flag <> "include>") then ! RETURN([flag,line]); ! elif (depth > 10) then ERROR(__("File inclusion nested more than 10 levels deep.")); fi; *************** *** 1513,1516 **** --- 1499,1504 ---- # make the file list from the comma separated filenames filelist := map(`Util/StripEndSpaces`,[`Util/CommaSplit`(line)]); + # expand EXAMPLES to path of examples directory + filelist := map(`aim/ExpandExamplesPath`, filelist); # ignore blank filenames filelist := remove(x->x="",filelist); *************** *** 1541,1545 **** newlines := newlines, ! `aim/Compile/ReadLines`(includefile,depth + 1); od; --- 1529,1533 ---- newlines := newlines, ! op(`aim/Compile/ReadLines`(includefile,depth + 1)); od; |