[Gd-chatter] r11536 - trunk/fundev/sources/lib/string-extensions
cgay at gwydiondylan.org
cgay at gwydiondylan.org
Wed Dec 12 09:04:36 CET 2007
Author: cgay
Date: Wed Dec 12 09:04:34 2007
New Revision: 11536
Modified:
trunk/fundev/sources/lib/string-extensions/library.dylan
trunk/fundev/sources/lib/string-extensions/parse-string.dylan
trunk/fundev/sources/lib/string-extensions/string-hacking.dylan
Log:
Bug: 7357
Added lookbehind method to <parse-string> and cleaned up the
module definitions a bit. I missed these files in r11533.
Modified: trunk/fundev/sources/lib/string-extensions/library.dylan
==============================================================================
--- trunk/fundev/sources/lib/string-extensions/library.dylan (original)
+++ trunk/fundev/sources/lib/string-extensions/library.dylan Wed Dec 12 09:04:34 2007
@@ -37,9 +37,13 @@
// use collection-extensions;
// use table-extensions;
export
- string-conversions, character-type, string-hacking, substring-search,
+ string-conversions,
+ character-type,
+ string-hacking,
+ substring-search,
// These last two are only to be used by the Regular-expressions library
- %parse-string, %do-replacement;
+ %parse-string,
+ %do-replacement;
end library string-extensions;
@@ -52,9 +56,19 @@
// use %Hash-Tables, export: {uppercase?};
export
case-insensitive-equal, // KJP: added
- alpha?, alphabetic?, digit?, alphanumeric?, whitespace?, uppercase?,
- lowercase?, hex-digit?, graphic?, printable?,
- punctuation?, control?, byte-character?;
+ alpha?,
+ alphabetic?,
+ alphanumeric?,
+ digit?,
+ whitespace?,
+ uppercase?,
+ lowercase?,
+ hex-digit?,
+ graphic?,
+ printable?,
+ punctuation?,
+ control?,
+ byte-character?;
end module character-type;
// For internal use and for use by the regexp library
@@ -62,7 +76,14 @@
define module %parse-string
use functional-dylan;
// use extensions;
- export <parse-string>, parse-string, parse-index, consume, lookahead, parse-string-done?;
+ export
+ <parse-string>,
+ parse-string,
+ parse-index,
+ consume,
+ lookahead,
+ lookbehind,
+ parse-string-done?;
end module %parse-string;
@@ -73,15 +94,12 @@
// use extensions;
use character-type;
use %parse-string;
- // Re-export case-insensitive-equal from table-extensions
- /* KJP: removed
- use table-extensions,
- import: {case-insensitive-equal},
- export: {case-insensitive-equal};
- */
export
- predecessor, successor, add-last,
- <character-set>, <case-sensitive-character-set>,
+ predecessor,
+ successor,
+ add-last,
+ <character-set>,
+ <case-sensitive-character-set>,
<case-insensitive-character-set>,
<byte-character-table>;
end module string-hacking;
@@ -93,17 +111,15 @@
//
define module string-conversions
use functional-dylan,
- export: { string-to-integer, integer-to-string }; // KJP: added
- /*
- use extensions,
- import: {<general-integer>, <extended-integer>, $maximum-integer,
- $minimum-integer};
- */
+ export: {
+ string-to-integer,
+ integer-to-string
+ };
use string-hacking;
use character-type;
export
- // string-to-integer, integer-to-string, // KJP: removed
- digit-to-integer, integer-to-digit;
+ digit-to-integer,
+ integer-to-digit;
end module string-conversions;
@@ -123,13 +139,11 @@
define module substring-search
use functional-dylan;
use character-type; // KJP: added
- // use extensions;
- /* KJP: removed
- use subseq;
- */
use string-hacking;
use %do-replacement;
export
- substring-position, make-substring-positioner,
- substring-replace, make-substring-replacer;
+ substring-position,
+ make-substring-positioner,
+ substring-replace,
+ make-substring-replacer;
end module substring-search;
Modified: trunk/fundev/sources/lib/string-extensions/parse-string.dylan
==============================================================================
--- trunk/fundev/sources/lib/string-extensions/parse-string.dylan (original)
+++ trunk/fundev/sources/lib/string-extensions/parse-string.dylan Wed Dec 12 09:04:34 2007
@@ -60,6 +60,17 @@
end if;
end method lookahead;
+define method lookbehind
+ (str :: <parse-string>, distance :: <integer>)
+ => (char :: false-or(<character>))
+ let index = str.parse-index - distance;
+ if (index >= 0)
+ str.parse-string[index]
+ else
+ #f
+ end
+end method lookbehind;
+
define method parse-string-done?
(s :: <parse-string>) => (answer :: <boolean>)
s.parse-index >= s.parse-string.size;
Modified: trunk/fundev/sources/lib/string-extensions/string-hacking.dylan
==============================================================================
--- trunk/fundev/sources/lib/string-extensions/string-hacking.dylan (original)
+++ trunk/fundev/sources/lib/string-extensions/string-hacking.dylan Wed Dec 12 09:04:34 2007
@@ -272,7 +272,6 @@
if (negated)
consume(s)
end;
-
let char-list = #();
let range-list = #();
until (lookahead(s) = #f) // until end of string
More information about the chatter
mailing list