From e3ea9032f6e3105d9c0a720db8bc413b4a3e016f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 24 Feb 2013 13:34:10 +0100 Subject: moved QuickSort macros from symbols-extract script into own string.tes macro library * therefore for bootstrapping to work, the SCITECOPATH is always set explicitly --- bootstrap.am | 5 +++-- lib/Makefile.am | 1 + lib/string.tes | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/symbols-extract.tes | 44 +------------------------------------------- 4 files changed, 50 insertions(+), 45 deletions(-) create mode 100644 lib/string.tes diff --git a/bootstrap.am b/bootstrap.am index 58a1aa1..fa15770 100644 --- a/bootstrap.am +++ b/bootstrap.am @@ -1,7 +1,8 @@ +BOOTSTRAP_SCITECO = SCITECOPATH=@top_srcdir@/lib if BOOTSTRAP -BOOTSTRAP_SCITECO = @top_builddir@/src/sciteco-minimal$(EXEEXT) +BOOTSTRAP_SCITECO += @top_builddir@/src/sciteco-minimal$(EXEEXT) else -BOOTSTRAP_SCITECO = @SCITECO@ +BOOTSTRAP_SCITECO += @SCITECO@ endif SUBST_MACRO = eb$<\e \ diff --git a/lib/Makefile.am b/lib/Makefile.am index 6bfb55a..5ac3d33 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,2 +1,3 @@ dist_scitecolib_DATA = lexer.tes fnkeys.tes +dist_scitecolib_DATA += string.tes diff --git a/lib/string.tes b/lib/string.tes new file mode 100644 index 0000000..274873b --- /dev/null +++ b/lib/string.tes @@ -0,0 +1,45 @@ +! String utility macros ! + +! M{symcasecmp} - Compare symbol at pos1 with symbol at pos2 (caseless) ! +@{symcasecmp}{ + U.2U.1 -.%.1 -.%.2 + @.#lo{ + U.v Q.v"W a-A%.v | Q.v"CQ.v|0' ' + } + + Q.c +} + +! M{exchange} - Exchange line at I with line at J (I < J), returning new J ! +@{exchange}{ + U.jU.i + Q.jJ X.xK + Q.iJ G.x .-Q.i%.j .-(X.xL.)%.j -K + Q.jJ G.x + Q.j +} + +! M{qsort} - Sort lines beginning at I until J using Quicksort algorithm ! +@{qsort}{ + U.rU.l + + Q.l-Q.r"< + Q.lU.i Q.rJB .U.j + + < + Q.iJ <.,Q.rM{symcasecmp}-1; .-Q.r; L> .U.i + Q.jJ <.,Q.rM{symcasecmp}:; .-Q.l-1:; B> .U.j + + Q.i-Q.j; + + Q.i,Q.jM{exchange}U.j + > + + Q.i,Q.rM{symcasecmp}"> Q.i,Q.rM{exchange}U.r ' + + Q.l-Q.i"< Q.iJB Q.l,.M{qsort} ' + Q.i-Q.r"< Q.iJL .,Q.rM{qsort} ' + ' +} diff --git a/src/symbols-extract.tes b/src/symbols-extract.tes index 48d749c..6e09380 100755 --- a/src/symbols-extract.tes +++ b/src/symbols-extract.tes @@ -1,49 +1,7 @@ #!./sciteco-minimal -m ! ./symbols-extract.tes ! -! M{symcasecmp} - Compare symbol at pos1 with symbol at pos2 (caseless) ! -@{symcasecmp}{ - U.2U.1 -.%.1 -.%.2 - @.#lo{ - U.v Q.v"W a-A%.v | Q.v"CQ.v|0' ' - } - - Q.c -} - -! M{exchange} - Exchange line at I with line at J (I < J), returning new J ! -@{exchange}{ - U.jU.i - Q.jJ X.xK - Q.iJ G.x .-Q.i%.j .-(X.xL.)%.j -K - Q.jJ G.x - Q.j -} - -! M{qsort} - Sort lines beginning at I until J using Quicksort algorithm ! -@{qsort}{ - U.rU.l - - Q.l-Q.r"< - Q.lU.i Q.rJB .U.j - - < - Q.iJ <.,Q.rM{symcasecmp}-1; .-Q.r; L> .U.i - Q.jJ <.,Q.rM{symcasecmp}:; .-Q.l-1:; B> .U.j - - Q.i-Q.j; - - Q.i,Q.jM{exchange}U.j - > - - Q.i,Q.rM{symcasecmp}"> Q.i,Q.rM{exchange}U.r ' - - Q.l-Q.i"< Q.iJB Q.l,.M{qsort} ' - Q.i-Q.r"< Q.iJL .,Q.rM{qsort} ' - ' -} +[.m EQ.mQ{$SCITECOPATH}/string.tes M.m ].m ! read commandline arguments ! LR 0X#in 2LR 0X#ou 2LR 0X#pa 2LR 0X#na HK -- cgit v1.2.3